Hot answers tagged


I'll try to illustrate this. This is valid JSON. { "errors": [ { "params": { "password": "size must be between 4 and 30", "loginId": "must match \"^[a-zA-Z0-9_]*$\"" } } ] } This is not: String str = '{ "errors": [ { "params": { "password": "size must be between 4 and 30", "...


Here's a parsing example using SSJS. If this were the value of the json attribute: [ { "sku":"123", "name":"Square", "url":"" }, { "sku":"456", "name":"Circle", "url":"" }, { "sku":"789", "name":"Triangle", "url":"


You can easily parse your String into Map and then serialize Map itself. Here is an example how to do it: String toMap = 'Profile:[UID=, crmId=0000o00002XXXXxXXX,, firstname=null, lastname=test]'; Map<String, String> ans = new Map<String, String>(); String actualValues = toMap.substringAfter(':'); actualValues = actualValues....


The heap limit is more of a "suggestion" than a hard rule. Having 13 MB of used heap isn't a big deal if you only do so briefly. However, there is a hard limit for strings; one single string cannot exceed the heap size limit. Similarly, JSON.deserialize (and related methods) will automatically fail if the string's size exceeds the total heap size (regardless ...


ANSWER: Escape the escapes. Because this is being handled both in Apex and as JSON, it seems they both need their own "\". Or should I say \"\\". Sorry, bad joke. Maybe others can offer even more detailed explanation. Change the part in question to: ...state.completion", "[{\\"name\\":\\"connect_adapt... and so on.


In case all values form JSON are comming as strings { "key" : "value" }, you can Map < String, Object > bodyMap = JSON.deserializeUntyped(req.requestBody.toString()); if (bodyMap.containsKey('age') && String.isNotEmpty((String)bodyMap.get('age')) { obj.someNumber = (Integer) bodyMap.get('age'); } do the same for all variables you ...

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