The JSON Parser reads and writes entries using the JavaScript Object Notation (JSON) format.
JSON is a lightweight data-interchange format and a subset of JavaScript programming language. JSON is built using the following two structures:
For detailed information about JSON format, see http://json.org.
The JSON parser reads and writes JSON formatted data. The JSON framework of IBM JavaScript Engine is used for mapping Java objects and JSON objects. The JsonFactory instance of JSON framework performs mapping between Tivoli Directory Integrator Entry or Attribute objects and basic JSON types such as object, string, array, number, or Boolean.
The data mapping in JSON is symmetric. JSON data mapped in and written out produces the same result. However, the order of properties might not entirely match the data read.
The following JSON data is an example, where simple values, arrays, and objects are nested.
{
"id": "0001",
"type": "donut",
"name": "Cake",
"ppu": 1.55,
"batters":
{
"batter":
[
{ "id": "1001", "type": "Regular" },
{ "id": "1002", "type": "Chocolate" },
{ "id": "1003", "type": "Blueberry" },
{ "id": "1004", "type": "Devil's Food" }
]
},
"topping":
[
{ "id": "5001", "type": "None" },
{ "id": "5002", "type": "Glazed" },
{ "id": "5005", "type": "Sugar" },
{ "id": "5007", "type": "Powdered Sugar" },
{ "id": "5006", "type": "Chocolate with Sprinkles" },
{ "id": "5003", "type": "Chocolate" },
{ "id": "5004", "type": "Maple" }
],
"simplearray":
[
"first value",
"second value",
"third value"
]
}
The above JSON data is mapped to the following Entry structure.
Entry.toDeltaString()
{
"#type": "generic",
"#count": 8,
"batters": [
"#type": "replace",
"#count": 1,
"#replace": ""batters": {
"batter": {
"batter": {
"id": "1001",
"type": "Regular"
},
"batter": {
"id": "1002",
"type": "Chocolate"
},
"batter": {
"id": "1003",
"type": "Blueberry"
},
"batter": {
"id": "1004",
"type": "Devil's Food"
}
}
}"
],
"id": [
"#type": "replace",
"#count": 1,
"#replace": "0001"
],
"name": [
"#type": "replace",
"#count": 1,
"#replace": "Cake"
],
"ppu": [
"#type": "replace",
"#count": 1,
"#replace": 1.55
],
"topping": {
"#type": "replace",
"#count": 0,
"topping": {
"#type": "replace",
"#count": 0,
"id": [
"#type": "replace",
"#count": 1,
"#replace": "5001"
],
"type": [
"#type": "replace",
"#count": 1,
"#replace": "None"
]
},
"topping": {
"#type": "replace",
"#count": 0,
"id": [
"#type": "replace",
"#count": 1,
"#replace": "5002"
],
"type": [
"#type": "replace",
"#count": 1,
"#replace": "Glazed"
]
},
"topping": {
"#type": "replace",
"#count": 0,
"id": [
"#type": "replace",
"#count": 1,
"#replace": "5005"
],
"type": [
"#type": "replace",
"#count": 1,
"#replace": "Sugar"
]
},
"topping": {
"#type": "replace",
"#count": 0,
"id": [
"#type": "replace",
"#count": 1,
"#replace": "5007"
],
"type": [
"#type": "replace",
"#count": 1,
"#replace": "Powdered Sugar"
]
},
"topping": {
"#type": "replace",
"#count": 0,
"id": [
"#type": "replace",
"#count": 1,
"#replace": "5006"
],
"type": [
"#type": "replace",
"#count": 1,
"#replace": "Chocolate with Sprinkles"
]
},
"topping": {
"#type": "replace",
"#count": 0,
"id": [
"#type": "replace",
"#count": 1,
"#replace": "5003"
],
"type": [
"#type": "replace",
"#count": 1,
"#replace": "Chocolate"
]
},
"topping": {
"#type": "replace",
"#count": 0,
"id": [
"#type": "replace",
"#count": 1,
"#replace": "5004"
],
"type": [
"#type": "replace",
"#count": 1,
"#replace": "Maple"
]
}
},
"type": [
"#type": "replace",
"#count": 1,
"#replace": "donut"
],
"simplearray": [
"#type": "replace",
"#count": 3,
"#replace": "first value",
"#replace": "second value",
"#replace": "third value"
]
}
The JSON Parser has the following parameters: