Activity Forums Salesforce® Discussions Mention what is the rule for JSON syntax rules? Give an example of JSON object in Salesforce?

  • Avnish Yadav

    Member
    August 8, 2018 at 6:18 am

    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.

    1. Data is in name/value pairs
    2. Data is separated by a comma
    3. Curly brackets hold objects
    4. 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.

  • Parul

    Member
    September 28, 2018 at 5:27 pm

    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.

Popular Salesforce Blogs

Popular Salesforce Videos