function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
KGDevKGDev 

Why serialize?

Could someone please explain me why do we want to serialize/de-serialize data? What is the idea behind it? What are good resources that explains the concept? I looked at the official salesforce documentation but it just gives examples but not the "why"?

Thank You!
Best Answer chosen by KGDev
Alain CabonAlain Cabon
@KGDev

We serialize/de-serialize data when we want to convert all the content of an object into a string for instance.

This string value of a serialization can be stored into a unique text field or sended/received with a webservice. 

We used the serialization to compare deeply and quickly a complex object by comparing just the complete serialized values.

The other common use is for the webservices with Json messages. 

These methods enable you to serialize objects into JSON-formatted strings and to deserialize JSON strings back into objects.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_json_json.htm

 

All Answers

Alain CabonAlain Cabon
@KGDev

We serialize/de-serialize data when we want to convert all the content of an object into a string for instance.

This string value of a serialization can be stored into a unique text field or sended/received with a webservice. 

We used the serialization to compare deeply and quickly a complex object by comparing just the complete serialized values.

The other common use is for the webservices with Json messages. 

These methods enable you to serialize objects into JSON-formatted strings and to deserialize JSON strings back into objects.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_json_json.htm

 
This was selected as the best answer
KGDevKGDev
Thank you Alain! I understand now.