JSON documents consist of fields, which are name-value pair objects. The fields can be in any order, and be nested or arranged in arrays.
There is no enforcement of document structures. Other documents in the same collection might therefore have a subset of these fields, extra fields, or different representations of the same field.
Data type | Example in JSON format |
---|---|
java.lang.String | "string" |
java.lang.Integer | 3 |
java.lang.Long | 4294967296 |
java.lang.Double | 6.2 |
java.lang.Byte [] | true / false |
java.util.Date (millisecond precision, in Coordinated Universal Time) | { "$binary": "(base64-encoded value)", "$type": "0" } |
java.util.regex.Pattern | { "$date" : "1998-03-11T17:14:12.456Z" } |
java.util.regex.Pattern | { "$regex" : "ab*" , "$options" : "" } |
java.util.UUID | { "$uuid" : "fb46f9a6-13df-41a2-a4e3-c77e85e747dd" } |
com.ibm.nosql.bson.types.ObjectId | { "$oid" : "51d2f200eefac17ea91d6831" } |
com.ibm.nosql.bson.types.Code | { "$code" : "mycode" } |
com.ibm.nosql.bson.types.CodeWScope | { "$code" : "i=i+1", "$scope" : {} } |
com.ibm.nosql.json.api.BasicDBObject | { "a" : 1, "b": { "c" : 2 } } |
com.ibm.nosql.json.api.BasicDBList | [1 , 2, "3", "abc", 5] |
For Date string values, the client converts the value to Coordinated Universal Time to be stored in DB2® databases. It is also retrieved as a Date in Coordinated Universal Time format.
9
{
name:"Joe",
age:25,
phone:["555-666-7777", "444-789-1234"],
homeAddress:
{street:"Sycamore Avenue",
city: “Gilroy”,
zipcode:"95046"
}
businessAddress:
{
street:"Bailey Avenue",
City: “San Jose”,
zipcode:"95141"
}
}