4.3.4.12. JSON
JSON (JavaScript Object Notation) is a lightweight text-based open standard designed for human-readable data interchange. It is derived from the JavaScript scripting language for representing simple data structures and associative arrays, called objects. Despite its relationship to JavaScript, it is language-independent, with parsers available for many languages. JSON format is often used for serializing and transmitting structured data for web applications.
The following properties are available:
To define a message in JSON format, select an existing template or make a copy of the generic JSON wizard in the catalogue and the following screen will be displayed.
File sample
Below is a sample of JSON file:
{ "id": "0001", "type": "donut", "name": "Cake", "ppu": 0.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" } ] }
Note: Regarding the Messages Out of type JSON each field in the last level of the tree will have a "type" attribute that will store the type to this field that will be used to validate the generated output message.
For example: Below is the tree of the above mentioned JSON file. The "type" attribute for the field "ppu" is float. This means that the generated output message for the "ppu" field will be validated if its value is a float value, as shown below:
If the input message for this field has a value of "75" or "8.5", the messages will be processed successfully. If the message has "Cake" value, which is a string, then the processed message will fail in error: Unparseable number: "Cake". This is because the value of "Cake" is string, not a float.
Below are the values that can be used in the "type" attribute (int, float, string, boolean, array).