JSON mapping
Data in Decision Server Insights can be represented in JavaScript Object Notation (JSON). Use the examples to map the data types of your business model definition into JSON.
Purpose
You can map the data types of your business model into JSON by using the examples. Data in JSON is either an object or an array. A JSON object is an unordered collection of names and values. A JSON array is an ordered sequence of values. A value can be a string, a number, a boolean, a null, an object, or an array.
The following business model definition (BMD) statement defines a concept named person.
a person is a concept with
a first name,
a last name,
an age(integer),
an address,
some phone numbers.
The following example shows the JSON representation of an instance of the person concept. The object has string values for first name and last name, a number value for age, an object value that represents the person's address, and an array value of phone number objects.
{
"$class": "Person",
"$CreationTime": null,
"$IdAttrib": "id",
"firstName": "John",
"lastName": "Doe",
"age": 25,
"address": {
"streetAddress": "20 rue jean d'arc",
"city": "Rouen",
"postalCode": 76000
},
"phoneNumbers": [
{
"type": "home",
"number": "0235066090"
},
{
"type": "mobile",
"number": "0648417050"
}
]
}
$is reserved for internal usage, for example $IdAttrib is an internal field. All $ prefixed attributes other than $class, $CreationTime, and $ref are ignored when you input data by JavaGateway API, REST, or connectivity.
The $class is used to refer to named BMD elements (entity, event, concept class names), or predefined class names like "int".
The $CreationTime attribute represents the creation time of an entity. It can be null.
The $ref attribute is used to reference existing content in the same JSON document. The $ref attribute value is a JSONPATH expression that is evaluated to retrieve the corresponding object. When the JSON payload is used in JavaScript, you can use JSON.retrocycle to get the right graph of objects. When the JSON payload is produced from JavaScript, you can use JSON.decycle to produce the $ref with the right JSONPATH expressions. For more information, see JSON in JavaScript.
Syntax
Business model elements | Business model definition example | JSON example |
---|---|---|
Attribute |
|
|
Concept |
|
|
Entity |
|
|
Enumeration |
|
|
Event |
|
|
List |
|
|
Multiple relationship |
|
|
Multiple relationship where each item is unique |
|
|
Reference |
|
|
Relationship |
|
|
Values | Business model definition example | JSON equivalent |
---|---|---|
Boolean |
|
|
Number |
|
|
String |
|
|
Object |
|
|
Values | Business model definition example | JSON equivalent |
---|---|---|
Geometry |
|
|
Point |
|
|