Questions tagged [deserialize]

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

Filter by
Sorted by
Tagged with
1 vote
2 answers
2k 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 ...
Robert Sösemann's user avatar
2 votes
1 answer
83 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 ...
Matt Smith's user avatar
0 votes
2 answers
3k 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 ...
Daryn's user avatar
  • 251
0 votes
1 answer
56 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":"...
user67794's user avatar
0 votes
1 answer
629 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 ...
Javier's user avatar
  • 33
0 votes
2 answers
2k 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;...
SfdcBat's user avatar
  • 4,721
2 votes
2 answers
3k 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 ...
Sfdcprgmr's user avatar
  • 357
0 votes
2 answers
2k 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....
BlondeSwan's user avatar
  • 1,058
1 vote
1 answer
3k 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 { ...
SavvyGoat's user avatar
1 vote
1 answer
261 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, ...
Thomas's user avatar
  • 2,284
1 vote
1 answer
507 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....
Zas's user avatar
  • 146
4 votes
1 answer
357 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> ...
number41's user avatar
  • 888
0 votes
1 answer
440 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 = ...
Madhurima's user avatar
  • 1,195
0 votes
1 answer
915 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(...
Richard's user avatar
  • 165
0 votes
2 answers
191 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 }, ...
Poornima's user avatar
2 votes
0 answers
84 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":...
wizard's user avatar
  • 413
1 vote
1 answer
457 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 ...
Padam's user avatar
  • 55
0 votes
1 answer
2k 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"},{"...
Padam's user avatar
  • 55
-3 votes
1 answer
136 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 ...
maria's user avatar
  • 51
0 votes
1 answer
126 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":...
Sisir's user avatar
  • 91
0 votes
1 answer
192 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", ...
Aishwarya's user avatar
0 votes
1 answer
83 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 ...
Randy B.'s user avatar
  • 139
0 votes
0 answers
250 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 ...
TheDevAdmin's user avatar
4 votes
1 answer
4k 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 ...
Brian Miller's user avatar
  • 4,997
0 votes
3 answers
1k views

Error: Malformed JSON: Expected '[' at the beginning of List/Set

JSON Response: { "caPerformanceRecordList": [ { "motorDealerID": "XL1HX", "dealerName": "Subaru Auto Dealer", "reportingPeriod": "2019-05-18", "...
GroundToCloud's user avatar
1 vote
0 answers
550 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 ...
JURY's user avatar
  • 173
0 votes
1 answer
406 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": {}...
user69684's user avatar
0 votes
1 answer
612 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 ...
user69684's user avatar
1 vote
1 answer
381 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": [ { ...
Rajesh's user avatar
  • 103
-5 votes
1 answer
1k 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;}...
Annappa's user avatar
  • 2,302
0 votes
2 answers
369 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 : ...
Brian Kessler's user avatar
1 vote
2 answers
2k 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 ...
Brian Kessler's user avatar
0 votes
1 answer
130 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 ...
Andrea Voggenreiter's user avatar
0 votes
1 answer
656 views

deserializing of json using wrapper class in apex

I have following type of json { "itemsPerPage" : 1, "links" : { "next" : "" }, "list" : [ { "id" : "19623", "resources" : { "reports" : { "allowed" : [ "GET" ], ...
user68022's user avatar
0 votes
0 answers
516 views

Unable to parse unicode characters as a string anymore

A few week ago, my api code that parsed a String just fine, all of the sudden doesn't work when the passed in string is unicode characters.. Here is my code: class Degree { String title; } class ...
BlondeSwan's user avatar
  • 1,058
1 vote
1 answer
50 views

Get value from deserialised JSON

I have a JSON string which looks like this: jsonstring = {"XX":["Blah blah"]} I need to get the 'Blah blah' into a string variable. How do I do this? Tried doing it this way, but all that returned ...
Irene's user avatar
  • 1,509
2 votes
1 answer
1k views

How to advoid Unknown field: MyJSON.number

I am having trouble with deserialising a jsonstring. In my debug I get the error System.JSONException: Unknown field: MyJSON.number. As number is a reserved field in salesforce I replace it with ...
Thomas's user avatar
  • 2,284
0 votes
1 answer
105 views

How to deserialize JSON?

I have an issue which I've been struggling with today. The JSON is returned back to me with a project Id as the key, this Project Id is dynamically generated and due to this I have not been able to ...
BreadMAN's user avatar
0 votes
1 answer
353 views

How to Deserialize the Trigger old & newMaps in JSON

I'm trying to pass the old & newmaps as arguments to a future method using JSON method. I see the below error when it tries to deserialize the data. reference-Passing SObjects to Future |...
Sam's user avatar
  • 21
1 vote
2 answers
2k views

Deserialize JSON Body into two different Lists of own classes

I'm writing an REST PUT request that takes in an array of Careers and Degrees from the body and converts them to inner classes within the RestResource class. However, when I am attempting to ...
BlondeSwan's user avatar
  • 1,058
0 votes
1 answer
2k views

How to parse nested objects in JSON response

Im trying to parse the below JSON response: { "preferredLanguage":"en", "preferredLocale":"en_GB", "languages":{ "en":{ "langCountry":"en-bn", ...
Jay's user avatar
  • 636
8 votes
1 answer
2k views

Deserialize hits memory limit

We have a custom apex webservice in which we do certain operations and later call a managed package apex method that returns a JSON string which we deserialize and send back to the client. For example ...
jonathanwiesel's user avatar
0 votes
1 answer
1k views

Deserializing/Parsing the JSON response to an Apex class

am trying to parse the below JSON request to Apex class. The challenge here is that one of the node "match" in the JSON is suppose to be an array but the external system sends it as a String. I would ...
SfdcBat's user avatar
  • 4,721
0 votes
0 answers
92 views

Parse a String as an Array using System.JSONParser [duplicate]

AN external system for some reason sends a node in a JSON as a String instead of an array like below: "vr_sch": "[{"type":"Record","tableName":"hpd","SId":"868","frequency":"ONCE"}]" The Apex class ...
SfdcBat's user avatar
  • 4,721
1 vote
1 answer
4k views

JSON.deserialize return null values

I'm trying to Test my Rest Web Service class. I want to simulate the process by taking a JSON and deserialize it to a class - Instead to create all the data by my self. But for some reason - all my ...
Salvation's user avatar
  • 1,087
0 votes
0 answers
91 views

Get JSONException with valid JSON. How to figure out what's wrong?

I have a bit of JSON coming from a mock that needs to de deserialized into an object. The JSON itself is perfectly valid. It has been validated by multiple services, and they all say it looks legit. ...
Willem Mulder's user avatar
0 votes
0 answers
188 views

how to deserializeuntype list<object>?

I have below JSON, that we are getting from external system and I am trying to use json.deserializeUntype to associate it to respective maps, objects etc. And then trying to insert into respective ...
user2945545's user avatar
2 votes
1 answer
2k views

JSON.deserialize on custom sObject not parsing related fields from lookup relationship

I've got a map whose values are a wrapper class. The wrapper class holds a custom sObject list, and the sObject in turn was queried to include related fields from a lookup relationship. Problem is, ...
smohyee's user avatar
  • 3,662
0 votes
1 answer
436 views

Malformed JSON: Expected '[': how to deserialize JSON with REST API?

Error: Malformed JSON: Expected '[' at the beginning of List/Set I think I have incorrect JSON.deserialize for my object. How can I fix it? I don't use a wrapper. List<Account> accList = new ...
user60684's user avatar
  • 143
1 vote
1 answer
288 views

HttpGet and Callout: is not a valid Salesforce ID for the type

I get Item's list from 1 organisation and want to insert them like Another Items in 2 organisation. But it try to insert it with Id. How can I fix that? Error: System.DmlException: Insert failed. ...
MichaelLev19's user avatar