How to control the format of associations in a JSON response
- Last Updated: January 29, 2025
- 1 minute read
- Corticon
- Documentation
Associations in JSON responses are, by default, expressed as a
JSONArray. You can control the format of 1-1 associations in JSON
responses by setting the property:
com.corticon.server.execution.json.association.singleton=JSONObjectin
the brms.properties on the machine where the JSON
requests are processed. When this property is set, and when a Rule alters a 1-1
association through an = (equals) operator, the entity
being assigned to the association will be expressed as a JSONObject, rather than an
entity inside a JSONArray in the JSON response. For example, here
Order is represented as an array, even though
there is only one order, a singleton. Note the square brackets: {
"Order":[
{
"OrderID":1,
"OrderName":"XYZ"
}
]
}
Here the same
Order is represented as a nested object: {
"Order":{
"OrderID":1,
"OrderName":"XYZ"
}
}This property will not unconditionally change 1-1 Associations from a JSONArray to a JSONObject in the JSON response. Changing from a JSONArray to a JSONObject will only occur when a Rule fires to alter the contents of an Association.