Questions tagged [deserialize]
The deserialize tag has no usage guidance, but it has a tag wiki.
179
questions
0
votes
1answer
32 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>...
0
votes
1answer
21 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": {
...
3
votes
2answers
30 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....
0
votes
1answer
19 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 ...
0
votes
1answer
34 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 ...
0
votes
2answers
55 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 ...
-1
votes
0answers
21 views
I want to deserialize JSON and store that data in salesforce based on noteID(upsert) [duplicate]
Below is my JSON response:-
{"notes":[{"noteID":2649475,"requestID":407414,"noteDate":"2020-12-29T06:00:28.0000000+00:00","note":"This ...
2
votes
1answer
26 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 + ' ...
-1
votes
1answer
36 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&...
1
vote
0answers
27 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 ...
0
votes
0answers
18 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
{&...
0
votes
2answers
70 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;
...
1
vote
2answers
110 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 ...
0
votes
1answer
17 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,...
0
votes
2answers
298 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,
...
1
vote
1answer
24 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 ...
0
votes
0answers
36 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 ...
1
vote
2answers
154 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 ...
2
votes
1answer
37 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
...
0
votes
2answers
83 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 ...
0
votes
1answer
38 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":"...
0
votes
1answer
128 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 ...
0
votes
2answers
240 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;...
2
votes
2answers
630 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 ...
0
votes
2answers
343 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....
0
votes
1answer
556 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 {
...
1
vote
1answer
53 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, ...
1
vote
1answer
67 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....
4
votes
1answer
218 views
Cannot use deserialized JSON for populating map - why?
I have deserialized some JSON into lists of objects:
Map<String, Object> Results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
List<Object> ...
0
votes
1answer
107 views
Deserialization using Apex class generated using JSON2Apex gives null for inner values
I have the following piece of code.
@RestResource(urlMapping='/Update')
global with sharing class OpportunityUpdate {
@HttpPost
global static void updateOpportunity() {
RestRequest req = ...
0
votes
1answer
120 views
Pulling values from inner curly brackets
I am trying to pull the values from a JSON response and have managed to get most of the values except the one I need which is nested in an inner set of curly brackets
public class web_ser {
@future(...
0
votes
2answers
76 views
Deserializing JSON
I am having trouble deserializing the JSON request received.
Below is the JSON format I receive,
{
header:{
worker count: 2},
Worker:{
name:emp1
},
...
2
votes
0answers
24 views
Dynamic Deserialization and merging of JSON Attachment
I have a requirement 2 merge old and newly created JSON attachment. There are no duplicates. The JSON have below format :
{
"productConfigurationId": "a06cdeghijklmnoABC",
"attributesByAttrDefId":...
1
vote
1answer
128 views
Apex Error Message : JSON Exception Error: No content to Map
The previous Question is linked here:
Apex Class Error Message: System.JSONException: No content to map to Object due to end of input
I have updated the code
If I use the below code where String is ...
0
votes
1answer
623 views
Apex Class Error Message: System.JSONException: No content to map to Object due to end of input
I am getting an Error in Apex when i try to Deserialize the JSON Response.
System.JSONException: No content to map to Object due to end of input
My JSON Response in debug Log is:
[{"recId":"1"},{"...
-3
votes
1answer
45 views
deserialize data from stringify data
I have read many posts regarding this but I m not able to to deserialize the data . So please can anyone help me with it.
serialized data:
"fieldlist" : JSON.stringify(selfield)
but I m not able ...
0
votes
1answer
21 views
deserialize a JSON and modify a single attribute in the list of Object
I have a JSON string as below from a http response.
{
"agreements": [
{
"agreementId": "ag0",
"publishedDate": "04-03-2016 00:00:00",
"AgreementNumber":...
0
votes
1answer
44 views
Retrieving data from JSON
I have this JSON data From where i have to fetch the "id"`
{
"_embedded": {
"users": [{
"id": "5d54e31886d2db014eefbf45",
"email": "vinothk@hibizsolutions.com",
...
0
votes
1answer
62 views
Invalid Conversion Runtime Type List<> to Map<>
I understand I am getting this error on the map line but I do not understand why. As the method does return the list I am constructing. What am I missing about this exactly?
The dataRequest starts as ...
0
votes
0answers
72 views
Variables from inner class defined by JSON deserialization are coming across as null
I have a class, geolocAddress, that I created to deserialize some JSON using JSON2Apex. I really only need to access the variables from one inner class, Components, but when I try to retrieve the ...
4
votes
1answer
1k views
JSON Serialize and Deserialize on HttpRequest
In order to make a @future(callout=true) call, I'm serializing an HTTPRequest object in order to send it to the @future method accepting a String jsonHttpRequest parameter.
Instance Method
...
0
votes
3answers
181 views
Error: Malformed JSON: Expected '[' at the beginning of List/Set
JSON Response:
{
"caPerformanceRecordList": [
{
"motorDealerID": "XL1HX",
"dealerName": "Subaru Auto Dealer",
"reportingPeriod": "2019-05-18",
"...
1
vote
0answers
235 views
JSON time fields
We have a problem with deserialize and serialize salesforce time fields
Since Json and salesforce time fields both consist of "colon" we need to replace with a special character before deserialize ...
0
votes
1answer
145 views
Malformed JSON: Expected '{' at the beginning of object while deserializing JSON..!
For this JSON When I tried to serialize using the class generated from json2Apex I am getting the error "Malformed JSON: Expected '{' at the beginning of object"
JSON:
{
"controllerValues": {}...
0
votes
1answer
158 views
How to deserialize the following JSON to get the list of values? [duplicate]
I have used the code below to deserialize the json but throwing an error.
Map<String,Object> root =(Map<String,Object>)JSON.deserializeUntyped(res.getBody()));
"Callout error Invalid ...
1
vote
1answer
217 views
JSON DeSerialization Help?
I am currently working on an integration with other systems and I have the JSON coming back in the below format.
{
"searchDocumentsResponse": {
"documentsIndexInfo": [
{
...
-5
votes
1answer
293 views
“Illegal assignment from Object” error
global class CasePRBugzilla_RestService{
global class cpb
{
public string Batch;
}
global class RecordIDS
{
string vmstarid {get;set;}
string gsid {get;set;}...
0
votes
2answers
71 views
Is it possible to create a generic Map swapper?
I have a method:
public Map<Object, Object> swap(Map<Object, Object> valueByKeyMap) {
Map<Object, Object> keyByValueMap = new Map<Object, Object>();
for (Object key : ...
1
vote
2answers
762 views
Is it possible to convert Map<Object, List<Object>> to Map<Id, List<SomeConcreteSObject>> without a loop?
As a Salesforce developer, I am frequently working with Maps and am looking to abstract the process of generating maps from SObject lists.
I've created the following helper class:
private class ...
0
votes
1answer
42 views
Restructure hierarchical data in a REST callout
I found contact data as JSON on the web that is not organized as the Contact sObject as the phone number is being stored as hierarchical data: please see https://api.androidhive.info/contacts/ for the ...