Key/Value Pairs

A key-value pair consists of a key and a value, separated by a colon.
The key is a string, which identifies the key-value pair.
The value can be any valid JSON value.
When you want to use key/value pairs, there are a few different formats you can use.

Syntax 1

This is an object containing key/value pairs.

{ "key1":"value1", "key2":"value2" } 

This format will not allow repeated keys (they must all be unique).
This format is popular when you do not need ordering.
An "employees" field containing an object of key/value pairs where the field is the key and the value is an object.

{ "employees" : { 
  "101" : { "employeeID":"101", "firstName":"John", "age":30, "city":"New York" },
  "102" : { "employeeID":"102", "firstName":"Anna", "age":22, "city":"London" }
} }

Syntax 2

This is an array of key/value pair objects.

[ {"key1": "value1"}, {"key2": "value2"} ] 

This format will allow for repeated keys.

Syntax 3

This is an array of a objects with Name and Value fields.

[ {"Name": "key1", "Value": "value1"}, {"Name": "key2", "Value": "value2"} ] 

© 2023 Better Solutions Limited. All Rights Reserved. © 2023 Better Solutions Limited TopPrevNext