Elements of JSON documents


A JSON document represents one serialized object or array that is delineated as follows:

  • An object is a comma-separated series of name-value pairs enclosed in braces.
  • An array is a comma-separated series of values enclosed in brackets.

JSON documents conform to the following rules:

  • A name-value pair consists of a name enclosed in quotation marks separated from the corresponding value by a colon. For example, "identifier" : 25 is a name-value pair. Whitespace between the name and value is insignificant.
  • A value can be a string, a number, an array, an object, or one of the following literal values: true, false, or null.
  • Strings must be enclosed in quotation marks.
  • Objects and arrays can be nested.

Examples

The following example shows a simple JSON document that consists of an object that only uses strings, numbers, and literals for the values:


{
  "name" : "Ed Smith",
  "reseller" : true,
  "company" : "Calbro Services",
  "street" : "123 Main Street",
  "city" : "San Jose",
  "state" : "CA"
  "zipCode" : "95134",
  "customerID": 1837
}

The following example shows a complex JSON document that contains nested elements. The JSON consists of a an object that uses strings, numbers, literals, arrays, and objects for the values. In the example,

  • contacts is an array of strings.
  • customerID is a number.
  • info is an object that contains
    • A literal boolean (isPrimary)
    • A nested object (address) that contains several strings (street, city, state, zipCode)
    • An array of numbers (orderNumbers).
  • companyName is a string. 


    {
      "contacts" : ["Maria", "Robert", "Edward"],
      "customerID" : 1837,
      "info" : {
         "isPrimary" : false,
         "address" : {
            "street" : "123 Main Street",
             "city" : "San Jose",
             "state" : "CA",
             "zipCode" : "95134"
         },
         "orderNumbers" : [123, 456, 789]
      },
      "companyName" : "Calbro Services"
    }

The following example shows a JSON document that consists of an array that contains three objects. Each object in the array contains two name-value pairs.


[
  {"name" : "Bob Garcia", "officer" : true},
  {"name" : "Maria Gray", "officer" : true},
  {"name" : "Jim Brando", "officer" : false}
]

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*

BMC Cloud Lifecycle Management 2.1.00