yesterday
Hi
I have a scenario where I'm using a parse Json and output structure is dynamic. here id and ans can be of any number or there'll be no id.
how can I add the data in the list?
example:
yesterday
Manually construct a fully-declared example and use that example in the parser. Like this:
//actual data with multiple objects
[
{"a": 1},
{"b": 2},
{"c": 3}
]
//fully-declared single object for parser
[
{
"a": 1,
"b": 2,
"c": 3
}
]
If the keys themselves are dynamic and you don't know what they'll be, then you'll have to take a different and more complicated approach.
19 hours ago
data I provided is just an example but in actual/sandbox/prod scenario it can be any number. so I want to understand the different and more complicated approach.
Thanks
18 hours ago - last edited 18 hours ago
Hi @nitishjain,
I have implemented a Python solution to structure the data effectively by differentiating employeeId and organizing ID-Ans pairs into a structured sublist. The output follows this format:
{ "employeeId": "010", "subList": [ { "id": "001", "ans": "001" }, { "id": "002", "ans": "002" }, { "id": "003", "ans": "003" } ] }
This structured approach ensures that each employee's data is efficiently stored in a list. I'm successfully appending it to a master list without any issues.
Final output looks:
{ "message": [ { "EmployeeList": [ { "employeeId": "010" } ], "subList": [ { "id": "001", "ans": "001" }, { "id": "002", "ans": "002" }, { "id": "003", "ans": "003" } ] }, { "EmployeeList": [ { "employeeId": "020" } ], "subList": [ { "id": "001", "ans": "001" } ] }, { "EmployeeList": [ { "employeeId": "030" } ], "subList": [] } ] }
Please let me know if you need further assistance.
Thanks and Regards,
Shivakumar K A