Activity › Forums › Salesforce® Discussions › Mention what is the rule for JSON syntax rules? Give an example of JSON object in Salesforce?
Tagged: Javascript Object, JSON Object, JSON Syntax Rules, Salesforce JSON, XML schema, XPath, XQuery, XSLT
-
Mention what is the rule for JSON syntax rules? Give an example of JSON object in Salesforce?
Posted by Prachi on August 7, 2018 at 1:40 PMMention what is the rule for JSON syntax rules? Give an example of JSON object?
Parul replied 7 years, 7 months ago 3 Members · 2 Replies -
2 Replies
-
Hi Prachi,
JSON is a simple data exchange format. JSON means JavaScript Object Notation; it is language and platform independent.
Syntax Rules for JSON:-
JSON syntax is a set of the JavaScript object notation syntax.
- Data is in name/value pairs
- Data is separated by a comma
- Curly brackets hold objects
- Square bracket holds arrays
JSON Object:- An object can be defined as an unordered set of name/value pairs. An object in JSON starts with {left brace} and finish or ends with {right brace}. Every name is followed by: (colon) and the name/value pairs are parted by, (comma).
Example:-
{
“glossary”: {
“title”: “example glossary”,
“GlossDiv”: {
“title”: “S”,
“GlossList”: {
“GlossEntry”: {
“ID”: “SGML”,
“SortAs”: “SGML”,
“GlossTerm”: “Standard Generalized Markup Language”,
“Acronym”: “SGML”,
“Abbrev”: “ISO 8879:1986”
“GlossSee”: “markup”
}
}
}
}
}Thanks.
- [adinserter block='9']
-
JSON
Pro:Simple syntax, which results in less “markup” overhead compared to XML.
Easy to use with JavaScript as the markup is a subset of JS object literal notation and has the same basic data types as JavaScript.
JSON Schema for description and datatype and structure validation
JsonPath for extracting information in deeply nested structures
Con:Simple syntax, only a handful of different data types are supported.
XML
Pro:Generalized markup; it is possible to create “dialects” for any kind of purpose
XML Schema for datatype, structure validation. Makes it also possible to create new datatypes
XSLT for transformation into different output formats
XPath/XQuery for extracting information in deeply nested structures
built in support for namespaces
Log In to reply.