Win a copy of Securing DevOps this week in the Security forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

FlexJSON for JDK 1.4 to with JQuery JqGrid  RSS feed

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm trying to convert a list of Pojo into a Jquery specific JSON string. Learned that FlexJSON does the trick. But it works only for JAVA 5. Does someone know the similar solution for JDK 1.4? I've done enough search over the internet but in vain so far.

Thanks
Vicky
 
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a lot of json libraries written in/for java. Google is your friend for that. I believe that http://stringtree.org/stringtree-json.html might work out for you though. Written by our very own staff member Frank Carver.
 
vicky kumar
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg,
I am specifically looking for JSON library that can genrate JqGRID (JQuery) specific JSON format. JqGrid demands a different JSON format for which you had mentioned to use FlexJSON in your blog. But that needs JAva 5. I am using JDK1.4. Look at the JSON format below for JqGrid:

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

The format above
cell:["cell11", "cell12", "cell13"]
is different than what JSON actually generates:
"cell":[{"key1:value1", "key2:value", "key3:value3"}]

Thanks
Vicky
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vicky, you are looking at the problem the wrong way. jqgrid can use a JSON response, yes and there is a specific pattern to it, not really a format. JSON can only be formatted one way. The trick was not getting the right JSON library but getting the Java objects right.

You can use any JSON library and assuming you use the objects that I created it should work.
 
vicky kumar
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Gregg. I actually got stuck in "deepserialize" whcih I think is
irrelevant. Its working now.

Vicky
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!