I am having a issue extracting values from a json array object that the array is dynamic therefore i can expect 2 array objects or 'n' object(s)...
now how can i extract these dynamic values from response and set to assign message.
for example:
{ "DateTime": "0119224502", "ResponseCode": "00", "StudentList": [ { "RELATIONSHIP_NUM": "185426", "STUDENT_ID": "60244", "STUDENT_STATUS_CODE": "001", "NAME": "Ali" }, { "RELATIONSHIP_NUM": "185427", "STUDENT_ID": "60245", "STUDENT_STATUS_CODE": "001", "NAME": "AZEEM" } ] }
now this StudentList is current giving 2 array objects in response but i can expect 'n' array obects in response.
Solved! Go to Solution.
thread solved... what i have done is that i used ExtractVariables with ther following path to extract the data:
<Variable name="SList"> <JSONPath>$.StudentList[*]</JSONPath> </Variable>
and then later to assign it:
{"StudentList":{ {SList} } }
I hope it might help someone who faces the same type of issue 🙂
What is the desired output?
You are showing an example input, and I understand there might be 2 elements in the StudentList array, or there might be more than 2.
What do you want to get out of that?
What do you want to map that input to?
thread solved... what i have done is that i used ExtractVariables with ther following path to extract the data:
<Variable name="SList"> <JSONPath>$.StudentList[*]</JSONPath> </Variable>
and then later to assign it:
{"StudentList":{ {SList} } }
I hope it might help someone who faces the same type of issue 🙂
This is working fine, when the array have more than 2 records. But if the array has only one record, Data won't be extracted
Example please.
HI @Dino, Thank you for prompt attention. It's working fine. No issue. Ignore my above comment.
what if the assign Message policy is in xml format? Please explain how to pass this array in xml type of assign message policy.
Hello,
I know the thread is already solved but I would also like to offer an alternative solution. You can parse the JSON using the javascript policy then set the value to a variable.
Sample JS policy:
Hope it helps!
Ryan
User | Count |
---|---|
3 | |
2 | |
1 | |
1 | |
1 |