As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [deserialize]

The tag has no usage guidance, but it has a tag wiki.

Filter by
Sorted by
Tagged with
0 votes
2 answers
529 views

How to deserialize json list, error: Invalid conversion from runtime type List<ANY> to List<or_leadsJSON>

I an trying to deserialize a Json string to use in my callout but get the error Invalid conversion from runtime type List<ANY> to List<or_guestsJSON> Callout HttpResponse response = ...
Thomas's user avatar
  • 2,284
1 vote
0 answers
244 views

How to minimise CPU usage doing JSON to Apex conversion across 70,000 lines?

Please help me finalizing Apex Wrapper Classes for parsing a very large JSON. JSON shown below comprises of product configuration data from ERP. (This JSON is usually 60k to 70k lines; it is scaled ...
SFDCLearner's user avatar
1 vote
1 answer
41 views

Json Parse Issue

I have very simple -sample class for the following json which I kept in custom label for simplicity. Sample JSON Which I have kept in Custom Label for simplicity : Label Name : Smple_Resp { "...
LWC_Beginner's user avatar
0 votes
2 answers
762 views

how to get a value after from result callout

I have the following where the result format of the callout is the following: [ { "uid": "72852a55-5be3-496c-904c-fc3fd261f0a4", "name": "Responseev Agency" }, { "uid": "66852a55-...
Thomas's user avatar
  • 2,284
1 vote
1 answer
901 views

How can I deserialize JSON with a (.) in the variable name?

I am getting following payload and am not sure how to deserialize it properly. Please note: I already used the JSON2Apex and the provided code did not work for me. Also, the actual payload is pretty ...
login2ak's user avatar
  • 151
0 votes
1 answer
451 views

Parsing different JSON bodies String vs List

Hi I have a Json body that can either send over a list vs a string. Right now I have it set to just capture a string "type" public class PackageInformation{ public String location {get;set;} ...
j.koh's user avatar
  • 27
0 votes
2 answers
232 views

How to deserialize my json result? [duplicate]

I'm calling one rest API and it's working properly but I'm not able to deserialize it's reesult. Below in mentioned my code and what response in I'm getting,I want city value in city variable and ...
Ranjeet Yadav's user avatar
-1 votes
1 answer
874 views

How to add duplicate fields in list in JSON deserialize method?

I need to parse this JSON and store services in a list but getting exception in deserialize due to duplicate field. Can someone help what I need to change to make this work? I have generated the class ...
shukla yogesh's user avatar
4 votes
2 answers
2k views

Is it possible to JSON.deserializeUntyped directly to DateTime without information about field is DateTime?

I wonder if it is possible to JSON.deserializeUntyped directly to DateTime type. How can I check if deserialized Object in Map has type of DateTime? I am curious is it possible, because Object in ...
Grzegorz Połuch's user avatar
0 votes
2 answers
733 views

Test Class Only Covers the Callout Method but the rest of the methods isn't

I have Mock callouts in my test class but the test class didn't cover some of the codes. It has been solved before but there were changes to my code and now my test class isn't working. The scenario ...
cookie's user avatar
  • 193
-1 votes
1 answer
2k views

Deserialize multiple level object JSON

So I am working with Google calendar data in the following format: { "kind": "calendar#events", "etag": "\"thEtag\"", "summary": "samuel.reyes@genko.com", "updated": "2018-08-20T18:11:13.081Z", "...
Genko's user avatar
  • 626
-1 votes
1 answer
128 views

Getting JSON String FATAL_ERROR System.TypeException: Invalid conversion from runtime type List<ANY> to Map<String,ANY>

I am suppose to be getting this JSON string but I am stuck with this error FATAL_ERROR System.TypeException: Invalid conversion from runtime type List to Map This is the JSON String: { "...
Janjan Dain's user avatar
4 votes
1 answer
2k views

Deserializing a list of jsons

I am trying to deserialize a list of jsons. If I have only one json like so '{"apple":"green"}' I can parse it using JSON.deserializeUntyped: Map<String, Object> input = (Map<String, ...
Arthlete's user avatar
  • 4,693
0 votes
1 answer
333 views

JSON deserialize with custom token

I need to deserialize an json where the token has special characters, but is not working as expected, it's not passing through the token and comparing to assign, am I forgetting something? controller:...
Thiago Balancin's user avatar
1 vote
1 answer
3k views

JSON deserializeuntyped function is shorting my response string

I have the following string as a response from a HttpResponse variable using its getBody() function: {"data":{"chat":[{"speaker":"Speaker 0","startTime":"0.16","message":"for technology positions so ...
Manu's user avatar
  • 43
1 vote
1 answer
3k views

Deserialize JSON string to custom Apex class

I'm building an API to show data in a Visualforce page. After I created the classes and the callout it responses with a JSON string. For now I use a mock JSON string to test my deserialize function. ...
Jeroen Joris's user avatar
0 votes
1 answer
190 views

JSON Deserialize

I am not able to deserialize my json JSON { "Services.ServiceContract_SAM_APIResponse": { "Services.ServiceContract_SAM_APIResult": { "Services.row": [ { "...
Nirav Shah's user avatar
0 votes
1 answer
58 views

JSON to Not Inserted Custom Objects to Map

I have a JSON response I receive from an endpoint, it is then deserialized, and all of the objects are stored in a custom object list (stored in the list variable "scope"). I am trying to place this ...
S.B.'s user avatar
  • 1,999
1 vote
2 answers
750 views

deserialize and then Iterating over a map

I'm creating a map in javascript I have a key as String and Value as SObject here is the function for the map var oMap = {}; function addValueToKey(key, value) { oMap[key] = finAccountMap[key] ||...
Amer Bearat's user avatar
-1 votes
1 answer
94 views

How do i deserailize this json string

Can Any one help me in deserializing this json string: "(ActivityHistory:{AccountId=0011a00000qWdtzAAC, Id=00T1a00001m4m99EAA, WhoId=0031a00000u3iXlAAI, Subject=Call, Status=Completed, Priority=...
Vee_force's user avatar
1 vote
1 answer
6k views

Parsing of JSON where a key contains spaces

I am trying to deserialize this response { "invoiceList":[ { "totalPrice":5.5, "statementDate":"2011-10-04T16:58:54.858Z", "lineItems":[ { ...
neelofer mohammad's user avatar
9 votes
1 answer
3k views

How to deserialize JSON to a class where the same variable name has different data types?

I am trying to deserialize some JSON to a class using JSON.deserialize. My JSON looks like this { "type": "GeometryCollection", "geometries": [ { "type": "Point", ...
Sam Maton's user avatar
  • 175
0 votes
2 answers
91 views

JSON key set to List conversion using deserializeUntyped

I am trying to extract the 'key' from a json an insert each key to a list (array). Map<String,Object> obj = (Map<String,Object>) JSON.deserializeUntyped(reqestObj); List<String> ...
saugandh k's user avatar
2 votes
2 answers
415 views

Lightning Component Issues Deserializing Integers

This is a result of my previous question Lightning component action responds with internal server error which I was finaly able to troubleshoot and resolve on my own. My original issue was that my ...
gNerb's user avatar
  • 9,342
0 votes
1 answer
5k views

Displaying JSON response data from a wrapper class onto a VF Page

I'm currently working on a small app, to allow to better understand RESTful Webservices and how to consume them. The app connects to a RESTful API, and I need to find a way to display the JSON ...
Adil Khan's user avatar
2 votes
1 answer
1k views

APEX Deserializing/Parsing RESTful JSON Webservice Response

I'm trying to get JSON data from a RESTful webservice into SFDC. My attempts have failed as I keep getting the following error: System.JSONException: Malformed JSON: Expected '{' at the beginning ...
Adil Khan's user avatar
2 votes
1 answer
345 views

deserialising JSON best practice/efficiently

I have the following JSON structure { "PLU":{ "high":"N/A", "low":"N/A", "percentChange":"0", "baseVolume":"0", "quoteVolume":"0" }, "1ST":{ "high":"0.00033386", "low":"0.00033386"...
JPG's user avatar
  • 188
1 vote
1 answer
970 views

Having trouble deserializing a JSON string of Objects

I'm trying to handle a JSON response..the format it comes in is not the best but I can't change it..Ive used JSON2APEX and can access the object values individually but I need to loop through them ...
JPG's user avatar
  • 188
10 votes
2 answers
1k views

Unfamiliar Syntax

I came across the following code online: @future(callout=true) public static void runWarehouseEquipmentSync(){ Http http = new Http(); HttpRequest request = new HttpRequest(); request....
Gabriel Rivera's user avatar
10 votes
2 answers
1k views

How to Deserialize AggregateResults?

Is it possible to deserialize AggregateResults? If not, why? When I try it the regular way, all my aggregate results are empty: List<AggregateResult> arList = [SELECT Name FROM Account GROUP BY ...
itsmebasti's user avatar
  • 6,280
5 votes
2 answers
736 views

Copy the properties from one instance of an Apex Class to another

I am attempting to copy the properties from one Apex class instance to another (without hard coding the property names). See the below example: public class Post{ public String name ...
structure's user avatar
  • 136
6 votes
1 answer
198 views

JSON.deserialize() for User records wont work

I'm trying to deserialize a received user record on a JSON format. TO achieve this I'm using JSON.deserialize() but when I specify the User class the compiler throws the following error: Save Error:...
Ismael Slimane's user avatar
11 votes
1 answer
3k views

How to deserialize into interface type when concrete type is unknown

As a follow up to this question: I am essentially trying to deserialize a JSON object into an Interface Type. Unfortunately we cannot deserialize using an Interface as the ApexType and must know ...
Eric's user avatar
  • 53.7k
2 votes
1 answer
10k views

System.JSONException: For input string

When ever i click on Upload Intent then works perfectly and i get response but when i click on status i get this json error, This is my VF, <apex:commandButton action="{!upload}" value="Upload ...
kishore's user avatar
  • 142
1 vote
1 answer
1k views

Unexpected parameter encountered during deserialization:

I am trying to create a rest endpoint. My JSON Body:- { "Name":"First Widget" } Apex Class:- @RestResource(urlMapping='/Widgets/*') global class WidgetController { @HttpPost global ...
veeran's user avatar
  • 13
19 votes
1 answer
1k views

Aura vs Apex - Deserialization and Interface discrepancy (Major rewrite with git repo)

Question rewritten and complete example code provided I am trying to write test methods for an aura implementation but am running into a roadblock where the JSON serialization/deserialization between ...
Eric's user avatar
  • 53.7k
2 votes
1 answer
3k views

Parser JSON array inside JSON array

I am facing issue with parsing jsonArray below { "name": [ { "actions": "test", "Items": [ { "Components": [ { "details": { ...
Sagar Hinsu's user avatar
1 vote
1 answer
984 views

refrain from unescaping special characters when receiving restcontext json?

I've set up an @RestResource class for receiving an external JSON webhook through an @httppost class, which is working great, but when retrieving the content of the request through RestContext.request....
mat's user avatar
  • 53
3 votes
1 answer
2k views

How to parse YAML object in Salesforce Apex

I get a YAML string from REST service response in Apex code and I look for some similar way how to parse it and convert to collection of Salesforce objects. For instance, I get such YAML as string: ...
Hleb's user avatar
  • 397
2 votes
1 answer
721 views

Json Deserialization

EDIT 2: Apparently Apex has no idea what escaping character is... after I removed manually all '\' from that JSON, it worked. I know this question was asked tens of times, but so far nothing works ...
vlado's user avatar
  • 29
0 votes
1 answer
74 views

How do I extract the value of the token from an HTTPRequest?

I've managed to login to the web and have received a token, but I can't seem to get my JSON.deserialize to give me just the token value. What should I be doing? string sToken = response.getBody(); ...
Irene's user avatar
  • 1,509
2 votes
1 answer
4k views

JSON deserialize a list of a list

I'm trying to deserialize the following JSON which I'm obtaning from the Google Cloud Platform Translation API: { "data": { "detections": [ [ { ...
Javier García Manzano's user avatar
1 vote
1 answer
747 views

JSON.deserializeUntyped problems with long list

I have this string s1 : {"iss":"backend","nbf":499071708,"iat":1499071708,"exp":2499071708,"Server":{"Version":"1.0","Identity":"backend"},"Data":{"ContentList":["AzEuMFveOpUnBpFTJ5yYdqdZxJs=","...
Raphym's user avatar
  • 177
1 vote
1 answer
607 views

Deserialising JSON with a '.' variable

I am attempting to deserialise a JSON response with some variables that Salesforce is having a problem handling because there is a '.' in the object name (as well as a '.' in some variable names). ...
Kamil Mieczakowski's user avatar
0 votes
2 answers
929 views

Trigger to fetch data and send it to field

This is probably really easy but I am completely new to Salesforce and struggling to find any tutorials on this. I have managed to deserialise a JSON object into the following wrapper: public class ...
Kamil Mieczakowski's user avatar
0 votes
1 answer
86 views

Deserialising JSON

I am trying to deserialise the following JSON object and get it to display on a visualforce page. However the fields displayed by the page are blank. I debugged the code to the point where I know I ...
Kamil Mieczakowski's user avatar
0 votes
0 answers
221 views

Selectively Parsing a JSON file

I am attempting to parse MatterMark's API, but I am planning to do so selectively, picking only the value pairs that are relevant. The example JSON response is available to be viewed in MatterMark's ...
Kamil Mieczakowski's user avatar
0 votes
2 answers
806 views

How to Deserialize the JSON response if it contains fields as test__c?

I am stuck as I have a response in the format shown below. Am not able to deserialize the fields appended with __c. "ReviewDetail": [{ "Request_Id__c": "", "Material_Requested_No__c":...
AnkushSalesforce's user avatar
4 votes
2 answers
5k views

System.TypeException: Invalid conversion from runtime type Map<String,ANY> to Map<String,String>

I have the following Program which gives me the following error: System.TypeException: Invalid conversion from runtime type Map<String,ANY> to Map<String,String> The program which I ...
user4567570's user avatar
  • 1,556
0 votes
1 answer
3k views

How to deserialize JSON to sObject?

I have following code and I'm trying to deserialize json array to list of sObjects, but I'm getting following exception without any message: System.JSONException: String dzejson = '[{"attributes":{...
Martin.Kona's user avatar