• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need your help in constrcting a JSON Response using a StringBuffer  RSS feed

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • 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 .
 
Sean Clark
Rancher
Posts: 377
Android Java Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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 Java Spring
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thank you , anybody who has worked on these ,please help .

 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • 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
  • 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

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just TRY one for goodness sake. Geez.
 
Michael Angstadt
Ranch Hand
Posts: 278
Eclipse IDE Java PHP
  • Mark post as helpful
  • send pies
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!