Reputation: 925
I would like to create the following JSON object in ESQL and put it on the SET OutputRoot.JSON.Data. How do I do that?
{
"active" : [ {"name" : "test"},
{"name": "test2"}]
"inactive" : [ {"name" : "test3"}]
}
Upvotes: 0
Views: 4103
Reputation: 51
The below snippet demonstrates how to create JSON you need:
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
-- Create JSON domain
CREATE LASTCHILD OF OutputRoot DOMAIN 'JSON' NAME 'JSON';
-- Create root Data field
CREATE FIELD OutputRoot.JSON.Data;
DECLARE OutMsg REFERENCE TO OutputRoot.JSON.Data;
CREATE FIELD OutMsg.active IDENTITY (JSON.Array)active;
SET OutMsg.active.Item[1].name = 'test';
SET OutMsg.active.Item[2].name = 'test2';
SET OutMsg.(JSON.Array)inactive.Item[1].name = 'test3';
RETURN TRUE;
END;
Also you can read more information about work with JSON here Manipulating messages in the JSON domain and here Creating or transforming a JSON message by using a message map
Upvotes: 1
Reputation: 2422
There is a standard procedure for IIB developers who want to output a specific format of XML/JSON:
Upvotes: 2