Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [deserialize]

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

Filter by
Sorted by
Tagged with
0 votes
1 answer
45 views

Handle with different type of params RestContext deserialize

We have a REST service that gets data from external service to salesforce. The data can be achieved using RestContext.request.requestBody.toString(); So I create an inner class to deserialize the ...
user avatar
  • 961
1 vote
0 answers
26 views

JSON deserialization of datetime - accepted format

I have an Apex REST API endpoint prepared that accepts DTO object. One of the fields in this object is of Datetime type. I was surprised that JSON.deserializeStrict accepts datetime to be of following ...
user avatar
  • 1,221
0 votes
0 answers
34 views

How to avoid governor limit while reading and deserializing a json attachment more than 4MB

I have a JSON attachment on ContentVersion object with the file size of 4MB, While trying the read the file and prepare the data for the custom report using lightning component it reached HEAP limit ...
user avatar
1 vote
0 answers
71 views

Issue in deserializing of List<Messaging.SingleEmailMessage>

I would like to send email with future apex. Because of future method can't access list of Messaging.SingleEmailMessage, I'm serializing it and pass string to future method. But when I deserialize it, ...
user avatar
1 vote
1 answer
65 views

How to get the field value from object. I am using deserializeUntyped

I am trying to get the field value from the object. If I loop through the object it looks like Map<String, Object> params = (Map<String, Object>)JSON.deserializeUntyped(RestContext.request....
user avatar
  • 229
1 vote
2 answers
461 views

Access Object property in APEX

Given the next code: Object deserializeResponse = JSON.deserializeUntyped(response); System.debug('DESERIALIZERESPONSE' + deserializeResponse); //DESERIALIZERESPONSE: {proposalIds=null, ...
user avatar
  • 157
0 votes
1 answer
149 views

Enable Map type to hold Integer, String, Boolean, Map, List... objects? (But not generic Object)

I'm attempting deserialize a list of a custom object in Apex, but got an error: FATAL_ERROR System.JSONException: Apex Type unsupported in JSON: Object This is because my ContactPostBack class ...
user avatar
  • 9
0 votes
1 answer
89 views

Deserialize dynamic json. Im handling reserved words fine but struggling to break free of hardcoding deserialization of __c and __ strings

Im deserializing a JSON (that has both reserved apex words and other uncompilable strings having 'organizer__' and '__c' ) in Apex. Ive been using a compiled class-based deserialization approach and ...
user avatar
  • 1,080
1 vote
1 answer
79 views

Declaration of Data Types Apex

I'm a new learner in Apex and I have a question about declaration of variables(A map in this case) and its Data type. I've been working with integrations and REST callouts and spend a long time when ...
user avatar
0 votes
2 answers
146 views

Get values in a List from JSON

I'm doing a REST API call to get the global value set and trying to deserialize the JSON result to get the picklist values in a List. Here is the JSON: { "size": 1, "totalSize"...
user avatar
  • 1
0 votes
0 answers
98 views

Error when deserealizing reply message from 'query' operation in .NET Core 3.1

I'm encountering the following error when using the query operation from the Salesforce SoapClient System.ServiceModel.CommunicationException: Error in deserializing body of reply message for ...
user avatar
8 votes
1 answer
380 views

Apex Json deserialize issue

I have observered an strange behaviour on JSON deserialize As per documentation deserialize(jsonString, apexType) If the JSON content contains attributes not present in the System.Type argument, such ...
user avatar
  • 2,444
0 votes
0 answers
60 views

how to handle date value blank in csv while deserialize in apex

I have build LWC for uploading the csv file and processing upsert/delete operation through batch class while while deseralizing the JSON string through JSONParser class if date column is present in ...
user avatar
0 votes
1 answer
183 views

JSON deserializeUntyped causing exception for a JSON data string

JSON deserializeUntyped is causing trouble and I could not understand why it would convert a Array of data to something that is neither an array nor a similar string? To reproduce I am executing this ...
user avatar
  • 5,596
0 votes
2 answers
140 views

Struggling to Deserialize this JSON in Apex [duplicate]

Here is my initial apex that currently functions and will return json. public class samCall { @AuraEnabled public static String samQuery(string accountDuns) { HttpRequest req = new ...
user avatar
1 vote
2 answers
685 views

Posting a JSON to the Salesforce REST API

I am trying to post the JSON to the Salesforce REST API, JSON getting posted to the REST service is like below [{"manager":"ABC", "name":"XYZ", "...
user avatar
  • 599
-1 votes
1 answer
41 views

Help with JSON.deserialize

@AuraEnabled public static String clone(Group__c destinationGroup) { Savepoint sp = Database.setSavepoint(); try { Group__c dest = (Group__c)JSON.deserialize(...
user avatar
1 vote
1 answer
90 views

How to test json.deserializeUntyped in trigger

I have a platform event trigger that takes in a json string which contains an array of objects. My postman test call looks like this: "testCodeList__c":"[{\"testCode\":\&...
user avatar
1 vote
1 answer
86 views

Issues and inconsistencies with Datetime deserialize and Datetime.parse()

I recently came accross this issue with Datetime deserialization. When using JSON.deserialize() with a random numeric value, the Datetime instance is created in a strange format, however, for the same ...
user avatar
0 votes
0 answers
343 views

Deserialize JSON to Object given an JSON String and an sObjectApiName

I created a generic LWC using a lightning-record-edit-form where user specifies sObjectName and fields to display as parameters and the edit form will display those. <lightning-record-edit-form ...
user avatar
  • 1,204
0 votes
1 answer
445 views

JSON.deserialize throws System.JSONException: Unexpected character error

I have a JSON String as below. String Input = {"body":"<style>p{margin-top:0px; margin-bottom:0px;}</style><body class=\"setupTab\" style=\" background-...
user avatar
0 votes
1 answer
371 views

How to loop trough second level deserializeUntyped Json String [duplicate]

PLEASE NOTE: deserializeUntyped not deserialize! I currently loop trough a jsonPayload which is working fine for the nodes of the first level.How can I achieve this for the node(s) of the second level ...
user avatar
  • 2,068
1 vote
1 answer
1k views

Ho to dynamically deserialize untyped a JSON with list

I have a JSON payload which is changing a lot so I want to create a way to dynamically deserialize the payload. My starting point is that the payload will consist of max 5 nested lists 5 levels deep. ...
user avatar
  • 2,068
0 votes
1 answer
127 views

Error: Invalid conversion from runtime type List<ANY> to Map<String,ANY>

I am trying to dynamically deserialize a jsonstring (fieldmaplevels wil also be in custom metadata settings) but get the error: Error: Invalid conversion from runtime type List to Map<String,ANY>...
user avatar
  • 2,068
0 votes
1 answer
68 views

How to manage both single and an array of json reponse from the same external system?

I have a situation where when I make a callout I get a single json response like this: { "Person": { "Infomration": { "IndividualInformation": { ...
user avatar
  • 456
3 votes
2 answers
104 views

How to deserialize object with nested query in a simply way

I have a JSON of object with nested query and I do not want to use JSON.deserializeUntyped and map values manually. Is there any easy way to do it? For example: Sobject object = (Sobject) JSON....
user avatar
0 votes
1 answer
185 views

Json deserialize System.NullPointerException: Attempt to de-reference a null object

I am trying to deserialize a json string and get the fieldtypes but get an error on the valueType. I am trying to simulate a Json request from postman to send a Post with a list of accounts. I dont ...
user avatar
  • 2,068
0 votes
1 answer
623 views

How to dynamically get name of object JSON String

I want to create a generic webservice. As I understood going the way of using Schema.getGlobalDescribe() will result in performance issues. I decided to try using JSON Schema trough Custom metadata ...
user avatar
  • 2,068
0 votes
2 answers
266 views

Is it possible to Generically deserialize a Json string wit nested arrays in Apex

I want to be able to Generically deserialize a Json string with nested arrays for a web-service, since the structure isn't known beforehand and kan change a lot. I did some reading a seems doable but ...
user avatar
  • 2,068
2 votes
1 answer
36 views

Why does deserializeUntyped interpret Strings starting with digits as Integers

This code List<String> ls = new List<String>{'32', '4text', 'text5'}; Object obj; for (String s : ls){ try{ obj = JSON.deserializeUntyped(s); System.debug(s + ' ...
user avatar
-1 votes
1 answer
292 views

Better way to do the JSON.deserializeUntyped to avoid cognitive complexity

I have use-case to call an external web service response in a Batch class. I have desterilized and build the Wrapper from the response like below, Sample Response { "status": "OK&...
user avatar
1 vote
0 answers
64 views

Custom object protected visibility failing JSON parser

My custom object in a DE org with a namespace has its visibility set to protected: Only Apex code in the same namespace can see the type. The name of the type and the record are visible if they're ...
user avatar
  • 3,764
0 votes
0 answers
19 views

How to remove unwanted attributes from a JSON [duplicate]

I have deserialized a JSON but the values are null. I suppose the issue here is the "Configurations". How can i remove/modify this so as the deserialization gets the proper values? JSON {&...
user avatar
0 votes
2 answers
657 views

Parse underscore named attribute from response's wrapper [duplicate]

I'm receiving some JSON from an API. I created a Wrapper like this: public class Wrapper{ public class cA{ List<cB> recordsB; public class cB{ cC recordC; ...
user avatar
1 vote
2 answers
722 views

How to deserialize list with map to wrapperclass

I have a string which I am trying to deserialize to a wrapperclass / object. But get the error: Expected Map<String,String> but found [line:1, column:3] Wrapperclass global class ...
user avatar
  • 2,068
0 votes
1 answer
71 views

Deserialize based on Child Class Apex Type

I am trying to deserialize a a serialized string of a child class from a static method. I have tried referenced the childClass from the static method, but it can't find it because it's a static method,...
user avatar
  • 1,818
0 votes
3 answers
2k views

How to parse json response with multiple records and add it to list

I have a json response from third party system which is as below. { "returnCode": 600, "lineItems": [ { "id": 9762, ...
user avatar
1 vote
1 answer
26 views

JSON Objects into string type

I have a doubt regarding the JSON deserialiser method. So when we deserialise a JSON response or JSON file. Is there a way to make every attribut and value into a string type rather than its original ...
user avatar
0 votes
0 answers
53 views

JSON deserialization issues

I have reviewed a lot of the other deserialize issues and I keep running into problems. What I have been able to gather is that if I have a response coming back with a reserved word in the JSON, I can ...
user avatar
  • 367
1 vote
2 answers
859 views

Handle unknown properties with typed JSON.deserialize()

I am looking for an elegant and unhacky way to handle deserialization of a JSON into an Apex type where some of the properties are known and some are not. Assumption: At least for now the unknown ...
user avatar
2 votes
1 answer
54 views

Deserialize Datetime from Custom Settings in Lightning Component

Is there a helper utility for Lightning components to convert values from Datetime objects into a deserialized value? I have two Datetime values in Custom Settings... My_Start_Date__c My_End_Date__c ...
user avatar
0 votes
2 answers
1k views

JSON deserialize test

In normal runtime everything seems to deserialize correctly but when I try to run a test class it throws the following error: System.JSONException: Unexpected character ('r' (code 114)): was ...
user avatar
  • 251
0 votes
1 answer
46 views

JSON deserializing not happening

I'm trying to deserialize a List of JSON objects in Apex. Here is the JSON being passed: [ { "Name":"TestUser1", "Interview_Information":{ "Interviewer":"JTA Test", "CandidateStage":"...
user avatar
0 votes
1 answer
414 views

Error deserializing json array nullpointer exception

I receive this json through a request {"pay_CCIban":"XXX", "pay_bic":"YYY", "pay_names[]":["name one","name two"], "pay_extid":"extId"} I'm trying to deserialize it with this class global class ...
user avatar
  • 33
0 votes
2 answers
1k views

Serialize and deserialize a list of Sobject for Future method

I am trying to pass a list Account records to a future method. Since future can only take primitives, I am planning to serialize and deserialize the Sobject. I tried below: List<Account> acList;...
user avatar
  • 4,521
2 votes
2 answers
2k views

How to adding dynamic rows/fields to wrapper class?

I have written the following WrapperClass, consisting different object records/rows/fields as members. How can I dynamically update this wrapper class object. In below code i have used only two fields ...
user avatar
  • 345
0 votes
2 answers
998 views

Deserialize an object with an optional field

I am trying to deserialize a request body but need to allow one of the fields to be optional. RequestBody { Decimal someNumber; } RequestBody reqBody = (RequestBody)JSON.deserialize(req....
user avatar
  • 1,000
1 vote
1 answer
2k views

Null object not so elegantly handled after JSON.deserialize()

According to this post, returning a blank list should handle nulls. But in my case it still complains that it's expecting something but found null. Here is my class: public class PersonProfile { ...
user avatar
1 vote
1 answer
94 views

Convert object as string to json

I have an object which is converted to string in a text field. How can I convert this to a JSON string. String of object: Profile:[UID=, crmId=0000o00002XXXXxXXX, email=top@top.com, firstname=null, ...
user avatar
  • 2,068
1 vote
1 answer
300 views

How to deserialize JSON string with serialized object as map value?

I have a JSON string which the value of 'clueContent' is a serialized JSON String. When I try to deserialize this JSON string to the resp2Obj inner class, it raise an error with message: 'System....
user avatar
  • 147

1
2 3 4 5