Questions tagged [serialize]
The serialize tag has no usage guidance.
33 questions
1
vote
1
answer
1k
views
JSON.serialize() Map<String, Object> changes Map structure
I have a Map<String,Object>() which I am trying to store in a text field for a subsequent asynchronous operation. My idea was for the following async operation to query for this map and re-use ...
0
votes
1
answer
2k
views
Getting Error: System.TypeException: Invalid conversion from runtime type List<ANY> to Map<String,ANY>
I'm getting error in the following apex method: System.TypeException: Invalid conversion from runtime type List to Map<String,ANY>
Please find the apex method:
@AuraEnabled(cacheable=true)
...
1
vote
1
answer
548
views
Not able to resolve Malformed JSON: Expected '{' at the beginning of object
I am having a simple JSON as like below
{"Stagename":"Prospecting","OppName":"MM - Opportunity","CloseDate":"2022-10-08","Phone":&...
0
votes
1
answer
305
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' =...
0
votes
1
answer
5k
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 {
@...
0
votes
3
answers
5k
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,
...
0
votes
1
answer
10k
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. ...
1
vote
1
answer
623
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 ...
-3
votes
1
answer
221
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 ...
6
votes
1
answer
5k
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
...
4
votes
3
answers
6k
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));...
0
votes
1
answer
2k
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 ...
0
votes
0
answers
32
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 ...
2
votes
1
answer
2k
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, ...
6
votes
1
answer
7k
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....
8
votes
3
answers
4k
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 ...
0
votes
1
answer
943
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": [
{
...
17
votes
1
answer
12k
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 ...
8
votes
2
answers
32k
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){
...
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", ...
3
votes
2
answers
301
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": "...
0
votes
1
answer
112
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 ...
1
vote
1
answer
1k
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/...
0
votes
1
answer
7k
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 ...
2
votes
2
answers
4k
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 ...
2
votes
2
answers
5k
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?
3
votes
1
answer
4k
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 ...
3
votes
1
answer
829
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....
1
vote
1
answer
117
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 ...
-2
votes
1
answer
5k
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 ...
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 ...
6
votes
1
answer
3k
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....
3
votes
1
answer
5k
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\":\"...