Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [deserialize]

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

0
votes
1answer
41 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
31 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 ...
0
votes
0answers
26 views

Why salesforce remote action response wrapped in extra keys?

I am calling simple remote action, and returning a response object, in my object I don't have any properties like "s" and "v" but they still appear in my raw json response. I am not sure whether ...
1
vote
1answer
89 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": [ { ...
-4
votes
1answer
61 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
46 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
205 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
28 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 ...
0
votes
1answer
32 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" ], ...
0
votes
0answers
20 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 ...
1
vote
1answer
17 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 ...
2
votes
1answer
34 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 ...
0
votes
1answer
34 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 ...
0
votes
1answer
27 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 |...
1
vote
2answers
109 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 ...
0
votes
1answer
472 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", ...
7
votes
1answer
466 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 ...
0
votes
1answer
93 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 ...
0
votes
0answers
43 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 ...
1
vote
1answer
644 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 ...
0
votes
0answers
27 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. ...
0
votes
1answer
385 views

capturing key and value of json as sobject field value

"element_properties":{ "label":"City", "Required":"TRUE", i have above json(which is not a full one though) where "label" even though is a key , i would need to store it ...
0
votes
0answers
56 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 ...
2
votes
1answer
215 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, ...
0
votes
1answer
88 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 ...
1
vote
1answer
34 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. ...
0
votes
2answers
60 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 = ...
1
vote
0answers
46 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 ...
1
vote
1answer
27 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 { "...
0
votes
2answers
78 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-...
0
votes
1answer
70 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 ...
0
votes
1answer
71 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;} ...
0
votes
2answers
46 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 ...
-1
votes
1answer
88 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 ...
3
votes
2answers
226 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 ...
0
votes
2answers
84 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 ...
-1
votes
1answer
297 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", "...
-1
votes
1answer
63 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: { "...
4
votes
1answer
83 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, ...
0
votes
1answer
88 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:...
1
vote
1answer
118 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 ...
0
votes
1answer
580 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. ...
0
votes
1answer
67 views

JSON Deserialize

I am not able to deserialize my json JSON { "Services.ServiceContract_SAM_APIResponse": { "Services.ServiceContract_SAM_APIResult": { "Services.row": [ { "...
0
votes
1answer
32 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 ...
1
vote
2answers
129 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] ||...
-1
votes
1answer
67 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=...
1
vote
1answer
1k 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":[ { ...
9
votes
1answer
976 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", ...
0
votes
2answers
36 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> ...
2
votes
2answers
172 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 ...