• 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

Need your help in constrcting a JSON Response using a StringBuffer

 
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,


Upon selecting a Country in one combo box , i am displaying all the channels related to taht Country inside another combobox

Curently i am constructing a JSOn response inside the Servlet using StringBuffer .

Constructing a JSOn response inside a servlet is some what complicated , are there any tools or API , taht will help

Thsi si what i am trying :





Could anybody please guide me , if this is the correct way of constructing a JSON response using a StringBuffer .

Thanks .
 
Rancher
Posts: 377
Android Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

I suggest you don't reinvent the wheel, there are lots of apis here JSON.

Sean
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Clark for the prompt reply .

Do you mean if i use JSON API i need not use StringBuffer to construct a JSON response ??

Do you please suggest what API should i use in JSON , for acheving my requirement
Thanks
 
Sean Clark
Rancher
Posts: 377
Android Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

Firstly, please call me Sean...

Do you mean if i use JSON API i need not use StringBuffer to construct a JSON response ??


That is correct you will not need to use StringBuffer to construct the JSON response as that is what the APIs are there to do.

Since JSON is a fairly simple concept I'm sure that any of the APIs will be able to help you achieve your requirement, personally I have only used the org.json one but perhaps there are other people who have tried others and can give you more of an insight into others on that list.

Sean
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you , anybody who has worked on these ,please help .

 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Help with what? As Sean said, generating JSON isn't rocket science. Just look at a few of the libraries and choose one that you like; you can't go wrong by much, if at all.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Help with what



I mean that there is JSON rpc , json.org , net.sf.json .

I dont know what package to pick from these things and one more question is that can i use JSONArray for this .

Thanks

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just TRY one for goodness sake. Geez.
 
Ranch Hand
Posts: 282
Eclipse IDE PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's actually better to use StringBuilder because it does not contain the thread-safe, synchronization overhead that StringBuffer does.

But yes, just use a JSON library.
 
reply
    Bookmark Topic Watch Topic
  • New Topic