tags:

views:

33

answers:

1

What's the best format for the JSON object for use in common Grids? I know this is a subjective question.

I've been writing a method to return a JSON object to represent some of our server side data. I've spent the last couple of days trying to fit the JSON object into a view, jqGrid in particular, I was about to demo how it might work in the real world. But I've found to my surprise that the client side ui grids are not very intuitive or configurable. So maybe I should change the format of my JSON object to make it fit the ui better!

Here's the type of structure my JSON objects will take is there a better way? As you'll see my structure has some nested objects.

{
    "Name": "Entity1",
    "Fields": {
               "field1": "22",
               "fieldString1": "init"
               },
     "Children": [
                  {
                     "Name": "ChildEntity",
                     "Fields": {
                               "fieldString2": "init",
                               "c_field1": "22"
                             },
                     "Children": [
                                ]
                   },
                    {
                      "Name": "ChildEntity2",
                      "Fields": {
                                "c2fieldString2": "",
                                 "c2field1": "22"
                                },
                      "Children": [
                                   ]
                     }
     ]
}
A: 

New line for each array element or object key-value-pair. Indentation by a fixed 2^k, k integer, k <- [0,4) (1, 2, 4, or 8) spaces per level of indentation.

{
    "key1": "value1",
    "key2": 3,
    "key3": [
        false,
        9,
        [ ],
        { },
        {
            "key4": {
                "key5": "value5"
            }
        }
    ]
}
Justice