WebFOCUS HTML5 JSON Syntax Basics

Reference:

JSON is an open standard format that uses attribute-value pairs written in plain text to define methods and properties. JSON is language-independent.


Top of page

x
Reference: JSON Object Definitions

An object is described using an unordered set of name-value pairs that define the properties of the object.

Each object name is followed by a colon (:), followed by a list of properties. The list is enclosed within a left brace ({) and a right brace (}).

Each property is a name-value pair. For example, a property may be the color of the object. That property has the name color. Its value is a color. For information about specifying colors, see Colors and Gradients.

A value can be a number, a string, a boolean value (true or false), a null value, an object, or an array. String values must be enclosed in single quotation marks (') or double quotation marks ("). For example:

color: 'green'

Each property is separated from the next property by a comma (,). Each object definition is also separated from the next object definition by a comma.

An object can consist of an array. For example, a chart can have multiple series (fields displayed by the request). Series within a request are numbered, starting from zero (0). Therefore, the series object consists of an array in which each member represents one series number. Arrays are enclosed within a left bracket ([) and a right bracket (]).

For example, the following series object describes the color property of first two series in a chart (series 0 and series 1). The numbers 0 and 1 are values for the series property, and the strings ‘cyan’ and ‘bisque’ are values for the color property:

series: [
{series: 0, color: 'cyan'},
{series: 1, color: 'bisque'}
]

An object can consist of multiple properties and objects.

For example, the following definitions for series 0 and series 1 define the color for each series and its marker and border objects. The marker object defines the shape and size properties of the marker. The border object defines the width and color properties of the border:

series: [
{series: 0, color: 'cyan', marker: {shape: 'triangle', size: 12, 
border: {width: 1, color:'blue'}}},
{series: 1, color: 'bisque', marker: {shape: 'square', size: 13, 
border: {width: 1, color:'brown'}}}
]

White space is not required within or between name-value pairs, but is recommended for clarity.

Note that brackets do not have to be placed on their own lines, but doing so and using indentations makes object definitions easier to identify. Similarly, each object in the array does not have to start on a new line, but starting each on a new line makes them easier to find.


WebFOCUS