PDA

View Full Version : JSONReader / Nested JSON



Bleak
14 Sep 2010, 5:45 PM
I have the following json;



{
"results": 1,
"data": [
{
"id": 22,
"audit_history": [
{
"id": 1,
"timestamp": "2010-09-14 20:43:37",
"action_id": 22,
"username": "Sheppard, Dean",
"description": "Created",
"user_id": 4
},
{
"id": 2,
"timestamp": "2010-09-15 20:23:37",
"action_id": 23,
"username": "Sheppard, Dean",
"description": "Created",
"user_id": 5
}
],
"assigned_to_username": "Fleese, Douglas",
"created_by_username": "Sheppard, Dean",
"status": "O",
"created": "2010-09-13 19:42:56.906",
"description": "Complete the project schedule.",
"project_id": 42,
"due_date": "2010-09-17",
"last_updated": "2010-09-14 11:02:59.281",
"user_id": 4,
"assigned_to_id": 2
}
],
"totalRecords": 1,
"success": true
}
I am attempting to map the audit_history in a record format for a JSONReader. Is it possible to have a single JSONReader handle the whole record, including the audit_history node since it repeats with a variable number of records?

Basically, I just want to map the audit_history node to a grid. I'm getting the impression that I will require a separate JSONStore with its own Reader to handle this nested node?

Looking to know if I am correct in my assumption that I can not map a single reader to manage both the audit_history node as well as the other attributes of the json.

duskandawn
15 Sep 2010, 4:24 AM
Just a quess, you can use the mapping function of the reader, to map to audit_history and then traverse through the variable sized array.