ibm-integration-busextended-sql

How to create a complex object in ESQL


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"}]
}

Solution

  • There is a standard procedure for IIB developers who want to output a specific format of XML/JSON:

    1. Use a text editor to create the document that you want to output
    2. Create a simple message flow that parses that document.
      • On the FileInput node (or HTTPInput, if you prefer) set the Domain to 'JSON'
      • Make sure that the second node is a Trace node with Pattern set to '${Root}'.
    3. Put the example JSON through the message flow
    4. Examine the Trace node output, paying special attention to the field type on each node
    5. Write ESQL that produces an identical message tree under OutputRoot.JSON.Data