Forum Discussion

andre_mangatal's avatar
andre_mangatal
New Contributor
7 years ago

Simple Help With JSON Splitter

Good day Snaplogic Community

This seems something simple but I am somewhat new to Snaplogic and I am returning a JSON from a REST GET which goes to a JSON Splitter with JSON path as $entity[*] but I would like to process each record in a mapper but I tried a couple expressions in the mapping input and it’s not working. If I have the JSON as below what would be is the expression for the expression field in the mapper be please? Thanks a lot in advance

[
{
“MPOS_Trans_ID”: 255,
“TransactionID”: “000000001”,
“GrandTotal”: 1,
“FullName”: “”,
“PolicyNo”: “”,
“Status”: 7,
“StatusName”: “NewUnprocessed”,
“RetryCount”: 0,
“ErrorMsg”: “”
},
{
“MPOS_Trans_ID”: 256,
“TransactionID”: “000000002”,
“GrandTotal”: 1,
“FullName”: “VISA ACQUIRER TEST/CARD 01”,
“PolicyNo”: “”,
“Status”: 7,
“StatusName”: “NewUnprocessed”,
“RetryCount”: 0,
“ErrorMsg”: “”
},
{
“MPOS_Trans_ID”: 257,
“TransactionID”: “000000003”,
“GrandTotal”: 5,
“FullName”: “”,
“PolicyNo”: “”,
“Status”: 7,
“StatusName”: “NewUnprocessed”,
“RetryCount”: 0,
“ErrorMsg”: “”
}
]

3 Replies

  • tstack's avatar
    tstack
    Former Employee

    The expression in the screenshot is:

    $entity.GrandTotal
    

    However, after splitting on $entity[*], the documents will only have the contents of the elements of the array. So, you should not have to add the $entity prefix and just write:

    $GrandTotal
    

    Although, I might not be understanding your question.

    One thing I do notice though is that there doesn’t seem to be any preview documents generated in your screenshot? If there were some preview docs, it would be a lot easier to see what was working or not.

    • andre_mangatal's avatar
      andre_mangatal
      New Contributor

      Hi tstack

      I implemented what you told me and it worked! Thank you so, so very much

      Best regards,
      Andre