Stack Exchange Network

Stack Exchange network consists of 174 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.

1
vote
2answers
27 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
294 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
352 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
45 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
41 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
238 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
24 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
83 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
46 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
57 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
32 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
25 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
37 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
30 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
25 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
43 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
35 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
39 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
33 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
53 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
79 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
74 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
148 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
47 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
51 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
65 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
61 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
340 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
56 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
28 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
82 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
58 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
883 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":[ { ...
8
votes
1answer
816 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
32 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
114 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 ...
0
votes
1answer
772 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 ...
3
votes
1answer
235 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 ...
2
votes
1answer
103 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"...
1
vote
1answer
487 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 ...
10
votes
2answers
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....
8
votes
2answers
374 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 ...
4
votes
2answers
86 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 ...
6
votes
1answer
112 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:...
10
votes
1answer
284 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 ...
1
vote
1answer
1k 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 ...
0
votes
1answer
174 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 ...
18
votes
1answer
462 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 ...
1
vote
1answer
1k views

Parser JSON array inside JSON array

I am facing issue with parsing jsonArray below { "name": [ { "actions": "test", "Items": [ { "Components": [ { "details": { ...
1
vote
1answer
219 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....