JqGrid Specifc JSON data format.

JqGrid Specifc JSON data format.

Hi,
I am using JqGrid and trying to paint my first Grid using a somple data returned from JSP/Servlet web container. I am usning Json-Lib library to convert my collection of JavaBeans into JSON format. But JqGrid seems accept a little different format. Does anyone know how can I can achieve converting a List of POJO into JqGrid specifc JSON data. Here is the difference ion format:

JqGrid Format:
------------------
{
total: "xxx",
page: "yyy",
records: "zzz",
rows : [
[id:"1", cell:["cell11", "cell12", "cell13"]],
[id:"2", cell:["cell21", "cell22", "cell23"]],
...
]
}

Json-Lib Java Returned format:
{
total: "xxx",
page: "yyy",
records: "zzz",
rows : [
//HERE IS THE PROBLEM. Look at the CURLY braces and key:value syntax.
{id:"1", "cell":{"cell11":"value", "cell12":"value", "cell13":"value"}},
{id:"2", "cell":{"cell21":"value", "cell22":"value", "cell23":"value"}},
]
}

At the very least I need to know how to convert a POJO into something like this:

Person {
String name:
int age:
String sex:
}

to a String like this:

["nameValue", "ageValue", "sexValue"]

Please let me know how can this be done. I'm stuck due to this.

Thanks
Vicky
    • Topic Participants

    • jlh