Hot answers tagged

6

The system that is sending you this payload is broken. The best way to address this problem is to fix the remote system so that it sends proper JSON. To address your question as asked, though: you are receiving this error because the first parameter of replaceAll() is a Java regular expression, not a string literal. The { character is being interpreted here ...


4

You can return your wrapper directly to LWC, no need to serialize: public class outputwrapper { @AuraEnabled public string key; @AuraEnabled public string total; } ... @AuraEnabled public static outputwrapper[] getStuffFromSystem() { outputwrapper[] results = new outputwrapper[0]; // ... // return results; } This would minimize the amount of work ...


4

You just need to deserialize the content again: Map<String, Object> payload = (Map<String, Object>)JSON.deserializeUntyped(responseJson); List<Object> results = (List<Object>)payload.get('result'); for(Object result: results) { Map<String, Object> resultContent = (Map<String, Object>)result; Map<String, Object&...


3

Short answer is that it should, but it doesn't. I am going off assumptions as I have no definitive proof, but even attempting to use the example in the official docs does not work. <ul class="people_list"> {{#each people}} <li>{{.this}}</li> {{/each}} </ul> using this data: { people: [ "Yehuda Katz", ...


3

If you were deserializing, this is a scenario where you'd use untyped deserialization. Since untyped deserialization keeps all of they keys as strings, reserved keywords are not an issue. Map<String, Object> untypedResult = (Map<String, Object>)JSON.deserializeUntyped(myJSON); // handling an untyped deserialization involves a lot of casting ...


2

str2 is not the string representation of an Id. ["0011H000023s57sQAA"] It looks like this is the string representation of a one-length string array containing an Id. Your JavaScript controller is sending the data incorrectly; you shouldn't need to stringify() an Id value. Instead, just access the first element of the array on the client-side ...


2

You're using the wrong type: myClass deserialization = (myClass)JSON.deserialize(serializedMyChildClass, myClass.myChildClass.class); Should be: myClass.myChildClass deserialization = (myClass.myChildClass)JSON.deserialize(serializedMyChildClass, myClass.myChildClass.class);


1

Unicode character 0xfeff is a BOM (Byte Order Mark), and not part of any valid Unicode character page. Some systems may emit this value at the beginning of a file, but Apex doesn't recognize those bytes, causing the problem you see here. As a quick fix, remove those values from the beginning, if present: String fixedString = EncodingUtil.convertFromHex( ...


1

You just need to give the output of your query a column alias, "Data". SELECT ( SELECT id AS [SubscriberKey], First_Name AS [FirstName], Last_Name AS [LastName], Email AS [EmailAddress], Phone AS [MobilePhone], Cover_Type AS [Need cover for] FROM [Health_Affiliate_Email_Capture] ...


1

Use JSON.deserializeUntyped instead (this gives you Map<String, Object> instead): NPS__c response = new NPS__c(); Map<String, Object> m = (Map<String,Object>) JSON.deserializeUntyped(JSON_from_email); for (String f : m.keySet()) { response.put(f, m.get(f)); } insert response; Also, if the payload already has the correct format, you ...


Only top voted, non community-wiki answers of a minimum length are eligible