Malformed JSON: Expected ‘[‘: how to deserialize JSON with REST API?

Error: Malformed JSON: Expected ‘[‘ at the beginning of List/Set I think I have incorrect JSON.deserialize for my object. How can I fix it? I don’t use a wrapper. List<Account> accList = new List<Account>(); public static HttpRequest createRequestForService(){ HttpRequest finalRequest = new HttpRequest(); finalRequest.setHeader(‘Authorization’,’Bearer ‘ + ‘my_token_here’); finalRequest.setHeader(‘Content-Type’,’application/json’); finalRequest.setHeader(‘accept’,’application/json’); finalRequest.setMethod(‘GET’); finalRequest.setEndpoint(‘https://name.salesforce.com/services/data/v44.0/query/?q=SELECT+Name+FROM+AnotherObject__c); return finalRequest; } //My … Read more

Adding Additional Fields to a sObject in Apex, (just for manipulation)

I’m working with some complicated queries, and I need to send over http, the sObject in turn, but I can’t make queries with more than 1 level of depth in the SOQL, so I am working with separated queries, then composing the sObjects, (or at least that is what I try), so I can created … Read more

How do I search a key or a value in a Nested Json object/array? [closed]

Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Salesforce Stack Exchange. Closed 3 years ago. Improve this question Assuming I have JSON data response as follows below and a Search Input on my lightning component. I want to search for … Read more

Extract values of the object received in the apex method!

I am passing in an object with mutiple rows of data, which eventually will be saved to the custom object. How do I extract the values of the object that I received in Aura enabled apex method. Controller js: var mduReport = []; var allUnits = component.get(“v.mduInfo”); for (let i=0; i < allUnits.length; i++) { … Read more

Json2apex – Message consuming unrecognized property

I am not able fetch all details for message & text fields node. Getting error as: Message consuming unrecognized property: name, Message consuming unrecognized property: userId, Message consuming unrecognized property: items, Message consuming unrecognized property: text, Message consuming unrecognised . Here is my json: { “messages”:[ { “type”:”ChatEstablished”, “message”:{ “name”:”Customer Support”, “userId”:”0056A000000ivth”, “items”:[ ], “sneakPeekEnabled”:true, … Read more

Invalid character in identifier

I am getting an error on my JSON2Apex class: Error:(7, 18) Invalid character in identifier: Holding_to_Fund__r Error:(44, 19) Invalid character in identifier: Holding_to_Fund__c I need to parse through some json that has a couple layers but the parser class can’t save. Is there a way around the issue it has with the ‘__r’ and ‘__c’? … Read more

How to get value from object Json.deserialize

I have deserialized a JSON object as follows: MyObjects MyA = (MyObjects) JSON.deserialize(req.requestBody.toString(),MyObjects.class); When I do MyA.get(‘Accounts’) my result is as follows ({AccountType=null, Addresses=null, Code=cd12345, Contacts=null, CreatedDate=null, CustomValues=null, Id=12345, ModifiedDate=null, Name=null, Relationships=null, …}) How do I get the value for Code? Answer I suggest you please elaborate a little more your question please. In addition … Read more

Access field values from JSON String in Lightning Component controller [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question PFB Code. I want to validate few fields before save but not able to fetch field values from JSON string. … Read more