• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Representation of JSON String

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to create a transport object in Java for a json string. I'm using jqGrid which is a jquery plugin and it accepts a json string representing the data in the table. Up to now I've hand coded the bits to take the data I need and construct the json String. I need to create a JavaBean that I can use a JSON library on to make things easier. But the json string I am dealing with is making me wonder if it is even going to be possible.



That is a short example of the format of the json. Any help is appreciated. If I get something close in the mean time I'll post back.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's what I've got so far:




Populating the data with a single row I get:



It's not too far off but I don't need the class names. That might just be an API issue.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I think if I can get rid of the class values, I'll have what I need.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep, adjusting the json library to exclude the "class" was all that was left. Problem solved.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anything else you need?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I notice that in the original sample input, total appears to be an integer, and everything else is a string. In your generated output, total is a string, and id is an integer. Don't know if it matters, but it may cause some mismatch problems later. Or not.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jim Yingst:
I notice that in the original sample input, total appears to be an integer, and everything else is a string. In your generated output, total is a string, and id is an integer. Don't know if it matters, but it may cause some mismatch problems later. Or not.


Thanks Jim. It doesn't seem to matter at the moment. I've blogged about the whole thing here.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see. So this was all just a ploy to pimp your blog. Got it.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jim Yingst:
I see. So this was all just a ploy to pimp your blog. Got it.


Darn. Busted.
 
vicky kumar
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gregg,
I read your blog and found out that you converted the Java Bean into JqGrid specific JSON string using FlexJSON which is build on Java 1.5. Is there any way I can do the same using JDK1.4? FlexJSON doesn't 1.5 binaries.
Please suggest...

Thanks
Vicky
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vicky,

You might get more luck posting your question in a new thread as we try not to WakeTheZombies
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic