Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [serialize]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
36 views

How can I generate arrays [...] to serialize an object? I want to make a simple JSON serialized

"Hello everyone". I have a couple of days with these json's. I have a json String done, like this: String payload = JSON.serialize( new Map<String, Object> { 'jsonrpc' =...
user avatar
0 votes
0 answers
23 views

JSON.serialize is NOT including NULL values regardless of suppressApexObjectNulls value [duplicate]

I'm trying to send an object's data out and I need it to include fields with null values. It is losing those fields when I serialize the object with the following code: for (Opportunity opp : Trigger....
user avatar
0 votes
1 answer
742 views

System.JSONException: Type cannot be serialized (Can't Serialize getSlots results into a JSON string)

Can't Serialize getSlots results into a JSON string and i get this error 'System.JSONException: Type cannot be serialized' ! please help ! This is my code : public class BookingServiceFslFlow { @...
user avatar
0 votes
3 answers
2k 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, ...
user avatar
0 votes
1 answer
5k views

forming a JSOn structure for data table in LWC

I have a wrapper class: Public class outputWrapper{ String key; String total; } I am creating this wrapper using a Apex controller. I use JSON.serialize(outputWrapper); to be returned to the JS. ...
user avatar
  • 4,521
1 vote
1 answer
249 views

SObject key of map mutated returns null but serializing returns the value

I am using a SObject as a key and mutating it. When I try to get the map value using the sobject, I get null. However, when i serialize the value, I can see the old value stored. Can anyone clarify ...
user avatar
  • 355
-3 votes
1 answer
59 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 ...
user avatar
  • 51
4 votes
1 answer
3k 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 ...
user avatar
  • 4,652
4 votes
3 answers
3k views

JSON.serialize: is it possible to suppress null values of a map?

I tried to serialize a map with null value (api 45): Map<String, String> bodyMap = new Map<String, String> {'key'=>'value', 'key2'=>null}; System.debug(JSON.serialize(bodyMap,true));...
user avatar
  • 323
0 votes
1 answer
1k views

How to serialize a custom Salesforce Class object with nested objects to json

I am a noob on serialising in SF. I have a SF object which i Want to serialise to JSON. The object contains nested data. Do I need to create all the nested data first an add these to the outer ...
user avatar
  • 2,068
0 votes
0 answers
31 views

Issue with the JSON object serialize [duplicate]

I am retrieving the list of all the fields and trying to serialize. Using the code snippet below allfieldNames contains around 400 fields but Data >>> contains information related to only 100 random ...
user avatar
2 votes
1 answer
1k views

Date Json.serialize removes 00:00:00 digits from datefields of object

I have the following object (invMappingNew): {customerId__c=1, addressId__c=8212BJ154, invoiceType__c=AdvancePayment, invoiceTypeLocalized__c=Voorschot, invoiceDate__c=2015-02-13 00:00:00, ...
user avatar
  • 2,068
6 votes
1 answer
4k views

JSON serialize SObject including fields with null values

I've currently got a use case where I would like to JSON serialize an SObject, but include fields with null (blank) values. According to the documentation (https://developer.salesforce.com/docs/atlas....
user avatar
7 votes
3 answers
3k views

JSON deserialize from another managed package

In Salesforce if you try and do this: JSON.serialize(data); where data is an instance of a global Apex class in another managed package it will fail. This seems like a completely arbitrary and ...
user avatar
  • 611
0 votes
1 answer
719 views

How to: JSON Serialize a node/list instead of a field

I have my class for serialize variables, but items and fields should be nodes not fields, I need to get this output: { "items": [ { "email": "string", "fields": [ { ...
user avatar
  • 405
12 votes
1 answer
8k views

How to JSON.serialize not including null values

I have an Issue. I have a class with few Strings public class DopplerJSONSerializer { public String name; public String email; } In some, I need to serialize and use only the name String in ...
user avatar
  • 405
8 votes
2 answers
19k views

Serialize a Map into a specific JSON object

I built a Map and serialized it into a JSON object, my code below: Map<String,List<String>> mapTypeSubType= new Map<String,List<String>>(); if(actionPlanB2C.size()>0){ ...
user avatar
2 votes
2 answers
2k views

Json serialize not giving me correct format

My end result needs to be something like this: [{ "label": "Sales", "color": "#9cd159", "data": [ ["Jan", 27], ["Feb", 82], ["Mar", 56], ["Oct", ...
user avatar
  • 866
3 votes
2 answers
300 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": "...
user avatar
0 votes
1 answer
76 views

Serialized JSON for POST to server not taking

I am following this simple example List<Account> accounts = [SELECT id, name FROM Account LIMIT 2]; String accountsJSON = JSON.serializePretty(accounts); I am trying to replicate this exactly ...
user avatar
  • 3,177
1 vote
1 answer
791 views

Substring for a specific value

I have below string value from which I need a specific section to put in another string. Can someone please help? String [{"attributes":{"type":"Call2_vod__c","url":"/services/data/v37.0/sobjects/...
user avatar
  • 2,900
0 votes
1 answer
5k views

how to use JSON.serialize() on a wrapper class ?

I want to use AngularJs in a my page to filter a list of records, i found this article very helpful. the problem is in the article, the JSON.serialize is applied on a list like this public static ...
user avatar
2 votes
2 answers
3k views

JSON Serialize returning html entities that are not encoded

I am getting data from a custom field(Article__c) on a Knowledge Article which contains HTML data. When I serialize this data and return it to a VF page I am getting HTML characters that should be ...
user avatar
  • 169
2 votes
2 answers
4k 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?
user avatar
  • 5,210
2 votes
1 answer
3k views

Changing property names when serializing JSON [duplicate]

Is there any way to set the name of the serializable field? I'm trying to work with JIRA webhooks and I ran into an issue where their request package contains a field that is a protected keyword in ...
user avatar
  • 9,446
3 votes
1 answer
686 views

JSON Serialize Anything

Sometimes as quick and drity debugging/introspection I leverage System.assert(false, JSON.serializePretty(<target>)) but it does not always work depending on target, ex: System....
user avatar
1 vote
1 answer
73 views

Deserialize and reserialize SOobject

i have an object like this: evticket__c et = [Select Id from evticket__c where Id =: id limit 1]; then i serialize it likethis: String obj = JSON.serialize(et); is there a way to create a new ...
user avatar
-2 votes
1 answer
3k views

why we need to serialize and deserialize

why we need to serialize and deserialize? Why don't we save the value directly into database with out serialize. What is the benefit for doing serialize. I know that by doing serialize it will get ...
user avatar
  • 3,671
2 votes
2 answers
2k views

How get all objects and their fields as Json

By means of Schema.getGlobalDescribe.Values () getDescribe ().getName () can receive names of objects.With Using method getDescribe().fields.getMap() we can get fields of object. It is necessary to ...
user avatar
  • 21
6 votes
1 answer
2k views

With JSON - How to serialize the Account's Shipping and Billing Address?

I want to serialize just the Address object (lets call it an object) of Account (and Contact as well) Is there a way to access the ShippingAddress/BillingAddress of the account using the JSON....
user avatar
  • 5,435
3 votes
1 answer
4k views

JSON.serialise give output with escape charater

I am doing this: JSON.serialize(payload); where payload is an object instance. and getting this: "{\"signup\":{\"salesforce_id\":\"003110022068XNz\",\"nationbuilder_id\":65536,\"last_name\":\"...
user avatar
  • 2,852