JSON Message Structure

JSON is easy to write, easy to read, and easy to translate between the data structures used by most languages. Let’s look at what makes up a JSON object, the data types that JSON supports, and other specifics with the syntax of this popular data format.

The criteria for valid JSON is rather elementary, though it can be used to describe complex data.

The structure of a JSON object is as follows:

  • Curly brackets {} hold objects (such as GetUserDetails)
  • Each data element is enclosed within double quotes (“ “) if it‘s a character, or without quotes if it is a numeric value
  • Commas ( , ) are used to separate pieces of data
  • The data are in key and value pairs. In the Example 1 below, a key is AccountId and a value is DemoUser
  • Square brackets [] hold arrays (an array is a list or collection of similar data elements)

As with all coding, it is recommended to follow a structured method of indentation to improve the readability of your messages.

Example 1. Basic JSON structure