Question
Lloyds Banking Group PLC
GB
Last activity: 13 Jul 2016 9:33 EDT
How to parse Array type JSON request using activity?
I have a requirement for read a JMS message (In JSON format) and create cases based on the JSON object inside the message. I understand I have to use adoptJSONArray function, but i am not sure how to use it. Can someone kindly let me know the syntax for the parsing code?
***Updated by moderator: Lochan. Removed user added Ask the Expert tag. Apologies for confusion, shouldn't have been an end-user option.
You need to call adoptJSONArray() on the ClipboardPage object that represents the clipboard page on which you want your data to be parsed and made available. This method takes two parameters. First is a string that holds the JSON array. Second is the name of a pagelist property to which the JSON array will be mapped.
For example,
String jsonArray = "[{\"name\":\"foo\"}, {\"name\":\"bar\"}]";
You want this JSON to be mapped to an embedded pagelist property called Names inside myStepPage (a ClipboardPage object onto which you want your data to be mapped), then you need to call (inside a try-catch block):
myStepPage.adoptJSONArray(jsonArray, "Names");