• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Representation of JSON String

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep, adjusting the json library to exclude the "class" was all that was left. Problem solved.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anything else you need?
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see. So this was all just a ploy to pimp your blog. Got it.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic