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 [serialization]

The tag has no usage guidance.

0
votes
0answers
37 views

How to store a collection type (set, map, list) on a object?

I have a visual-force page which displays an Apex form with some dynamic number of input text fields that I would like to save on the Opportunity object. Is the easiest way to serialize them as JSON ...
4
votes
1answer
74 views

JSON serialization across managed packages

We're having an ecosystem of managed packages where one is dependend on another and sometimes there is a need that one package (e.g. extension package) need to serialize some objects from another ...
2
votes
2answers
121 views

How to control the property name of a serialised object using Apex

BACKGROUND I need to generate the below JSON data: JSON { "Type": "ACCPAYCREDIT", "Status": "AUTHORISED", "Contact": { "ContactID": "eaa28f49-6028-4b6e-bb12-d8f6278073fc" }, "Date": ...
2
votes
1answer
834 views

How to return Json string

I have a Get Method which returns an invoice based on id. When I test this with Workbench I would like to have the following response: { "customerId": "1", "addressId": "2018AA123", "invoiceId": "...
0
votes
1answer
79 views

Convert Multile Objects to a single json

I have a list of map and list objects. These objects needs to be sent as json content in an http request. The objects are Map<String,String> leftFileParameters = new Map<String,String>()...
1
vote
1answer
321 views

JSON.serialize Url object throwing System.JSONException

I'm getting the following JSONException when JSON serializing a Map of generic Objects which contains a Url object deeply nested within. System.JSONException: Type unsupported in JSON: common.apex....
1
vote
1answer
84 views

How to build and serialize

Keith C's answer builds the following "config" output: config: {option1: {isActive: true, isRequired: true}, option2: {isActive: true, isRequired: true} } by looping ...
1
vote
1answer
288 views

JSON Deserialization in RemoteAction causing Salesforce system error

I have the following class being called from a @remoteAction. Specifically, the toFormObject() method is being called, and when it gets to the JSON.serialize, it is exploding FATAL_ERROR System....
-3
votes
2answers
9k views

Create JSON using apex

I do not have any idea about this, but I am trying to create JSON using Apex class. I think it can be done using serialize method. But I need a simple example so that I can understand the procedure. ...
0
votes
1answer
174 views

Error desearlizing JSON of type BatchInfo - Bulk API

I am trying to get the status,# record processed etc details by hitting the bulk API endpoint - /services/async/39.0/job/75037000003BXtw/batch In response I got the below JSON structure: {"batchInfo"...
0
votes
0answers
119 views

Apex: Making key lowercased in json serialized version of object

The usual way to serialize hierarchy of objects in json looks like this in Apex: String json = JSON.serialize(rootNode); My requirement is to send this json to our external system. But they want to ...
1
vote
0answers
194 views

json.serialize returning null

List<ClassName.CustomerDetails> CustomerDetailsList = new List<ClassName.CustomerDetails> (); ClassName.CustomerDetails custDetails = new ClassName.CustomerDetails(); ...
1
vote
2answers
424 views

Making “Null” as “” in JSON payload

I am trying to push a JSON input payload, but some fields might be blank. The receiving system has a problem with it. They want either the blank fields to not be sent all together or replace "Null" ...
4
votes
2answers
2k views

System.TypeException: Invalid conversion from runtime type Map<String,ANY> to Map<String,String>

I have the following Program which gives me the following error: System.TypeException: Invalid conversion from runtime type Map<String,ANY> to Map<String,String> The program which I ...
6
votes
1answer
1k views

deserializeStrict method: bug?

The documentation about the deserializeStrict method in JSON class is (emphasis added): All attributes in the JSON string must be present in the specified type. If the JSON content contains ...
3
votes
1answer
586 views

I want to pass an HttpRequest object to a Class that implements the Queueable interface

This is similar to this question, but I'm wondering about the object I'm sending into the Queueable Class. Here's the Queuable Class (not much more than debug statements at this point) public class ...
4
votes
2answers
280 views

Deserialise json in apex

How to deserialize the below json ? I want to retrieve messages only in list of string . { "posts": { "data": [ { "message": "Hello. My name is sdfd. How can I help you?", "created_time": "...
1
vote
1answer
262 views

getChildElement element failing null pointer exception

I have the below XML response which I am trying to parse through XML parser. But I am facing error i.e null pointer exception in debug log for the line: if(objXMLNode.getChildElement('...
10
votes
1answer
383 views

Most Efficient Method to Convert Set Type?

I have a twist on this question. What is the relative performance of each of the following methods? Via Peter Knolle: public static Set<String> deserializeToStrings(Set<Id> input) { ...
2
votes
1answer
243 views

Serialize JSON attribute that is a reserved keyword in Apex

To use the Javascript tree library DynaTree on my Visualforce page I create JSON data in its controller List<DynaTreeNode> rootNodes = nodesByParentId.get(null).values(); dynaTreeJson = JSON....
2
votes
3answers
978 views

Convert SObjects containing child/parent records into a map

How can the following list of records be serialized/deserialized into a map or collection? Account[] accs = [select id, name, custom_parent__r.name, (select lastname, firstname from Contacts) from ...
9
votes
1answer
14k views

Deserialize JSON to SObject

Following code is giving me common.apex.runtime.impl.ExecutionException String jsonText = '{"Data": {"attributes": {"type": "Contact"},"Id": "0036100000JUXKkAAP","Description": "","LastName": "...
6
votes
1answer
565 views

Why does JSON.Serialize return null when passed a value of type System.Address?

Background I'm working on a project where I'm communicating with an external billing system to create a new Account in our external billing system when a new Account is created in Salesforce. Being ...
1
vote
2answers
1k views

What is the best way to create XML from a custom object and use that xml to create records of another custom object?

I have two custom objects . How to transfer the records from one custom object to another using xml ?
0
votes
0answers
367 views

Unexpected parameter encountered during deserialization

I am trying to write a REST service which will send SF objects between Orgs. Right now, as a test, I am sending data to the same Org that it is coming from. I wrote a GET request which worked so I ...
2
votes
2answers
3k views

What XML support salesforce provides in apex

(i) Is it possible to directly serialize/deserialize sObject record to xml in apex code? (ii) Is it possible to serialize/deserialize apex object to/from xml?
2
votes
1answer
1k views

Dynamically serialize or deserialize properties in apex

I want to have dynamic properties in my JSON structure, something like this - { "payload": { "one": { "x": 1 }, "two": { "x": ...
6
votes
2answers
309 views

Is there any logic to how SFDC serializes classes to JSON?

I'm working on documentation for a number of APEX REST API endpoints which returned user-defined types. I'm struggling to write the documentation since the order of how things are serialized into JSON ...
1
vote
1answer
804 views

salesforce .net toolkit relationship query serialization

I created strongly type classes to use when using the toolkit to query salesforce public class SFAccount { public string Id { get; set; } public string Name { get; set; } public ...
5
votes
0answers
258 views

JSON.serialize alternative which support more objects like HttpRequest or Schema Describes

Often I need a easy and robust way to convert huge nested data structures into an string. Mostly for dumps, logs and debug. JSON.serializePretty() comes close but does not support all Object types ...
5
votes
2answers
3k views

Apex Rest JSON serialization Error: Invalid type for Http* method: …Map.Object

Background I'm developing some generics apex web service (Rest). The response should be an standardised json schema like this: { "res": true, "message": "Records Upserted Ok", "data" : {ANYTHING}...
5
votes
1answer
479 views

How to JSON.serialize an opportunities line items?

How can I JSON.serialize an opportunities line items? I need to create a single json file, that holds an oppty as well as it's line items. If I just JSON.serialize(opportunity), I get all the Oppty'...
19
votes
2answers
2k views

What are the different capabilities between the @RemoteAction serializer and JSON.serialize?

I've been working quite a bit with @RemoteAction methods and have noticed there seem to be a few inconsistencies between what's allowed in the apex JSON.(de)serialize methods and what the automatic ...
3
votes
1answer
2k views

Unable to deserialize json data accessed from salesforce object in asp.net

I need to access data records from salesforce object. I got the json response.The json document is given below, { "totalSize":2, "done":true, "records": [{"attributes": { "type":"...