Send master detail JSON from AR

Hi All,

I’m having difficulty on constructing master-detail JSON message. For example I have sales header and detail record:

sales header: sales_no, sales_date, sales_person, customer_name

sales detail: sales_no, item_id, item_description, qty

one sales header can contain many sales detail, for example:

sales header:

  • sales_no: sales1

  • sales_date: 2016-10-26

  • sales_person: john

  • customer_name: susy

sales item #1:

  • sales_no: sales1

  • item_id: item1

  • item_description: item one

  • qty: 2

sales item #2:

  • sales_no: sales1

  • item_id: item2

  • item_description: item two

  • qty: 5

below is the expected message

{"sales_no": "sales1", "sales_date": "2016-10-26", "sales_person": "john", "customer_name": "susy", 

"sales_details": [

{"sales_no": "sales1", "item_id": "item1", "item_description": "item one", "qty": "2"}, 

{"sales_no": "sales1", "item_id": "item2", "item_description": "item two", "qty": "5"}]}

grateful if someone can share experience on how to achieve this, and how to read the message after receiving it.

Thank you,