Integration

Get Involved. Join the Conversation.

Topic

    David Tran
    Mapping to complex JSON for REST post
    Topic posted August 14, 2019 by David TranRed Ribbon: 250+ Points, tagged Adapters, API, Connection, Mapping, Orchestration, PaaS, REST 
    26 Views, 2 Comments
    Title:
    Mapping to complex JSON for REST post
    Summary:
    Mapping to a complex json in OIC
    Content:

    Hello Cloud People

    I was wondering if someone can give an example of how to map to a complex 3 level json for a REST post from OIC.

    Use case: 

    This is for a sales order  where an order has multiple items, those items can and will have quantities greater than 1 and each of those quantities will have a serial number attached to it

    So far, I'm able to get single items with the serial numbers but cannot figure out how to get multiple items with serial numbers into a json.

    Example of what is needed

    {
      "sales order": {
        "InvoiceNumber": "132456789",
        "items": [
          {
            "ItemName": "laptop model 1",
            "QTY": 4,
            "serialNumbers": [
              123,
              234,
              345,
              456
            ]
          },
          {
            "ItemName": "mouse model x1",
            "QTY": 2,
            "serialNumbers": [
              321,
              432
            ]
          }
        ]
      }
    }

     

    Can someone please give me pointers on how to map this beast?

     

    Comment

     

    • Jorge Herreria

      Can you provide more details?

      In the Orchestration, the REST responses get translated into XML... So I cannot connect the dots you trying to read a JSON object.

      1. Where in the orchestration you are seeing the JSON?
      2. How have you achieved seeing a single item?
      3. Can you provide your desired output example?

       

    • Hemanth Lakkaraju

      Assuming the sampling of JSON is done correctly (like using exact sample as below)::

      items in this case would be a repeating element. So use a for-each in your source and map accordingly or right click and say repeat the element and then do individual mapping.

      Same with the case of serialNumbers within items element.