| Author |
Servlet JSON response
|
leo donahue
Ranch Hand
Joined: Apr 17, 2003
Posts: 327
|
|
I'm just asking for the sake of clarity, but if a servlet returns a varying JSON response, does that make it a web service?
Ex: http://somehost/xyzservlet?param1=foo¶m2=bar
Varying param1 and param2 can yield different JSON responses. Is this considered a "web service"?
|
Thanks, leo
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
|
|
I guess that greatly depends upon how you define "web service"?
I'll move this over to the web services forum for any further discussion.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
|
|
For what it's worth, a large number of the servlets in my current project return JSON, as the app is heavily Ajax-ified. I do not consider these servlets part of any "web service".
(We do have a RESTful web service for the system -- but it's XML-based.)
|
 |
leo donahue
Ranch Hand
Joined: Apr 17, 2003
Posts: 327
|
|
Just curious to see what people thought.
Do most people create their own process for converting Java HashMap Objects to JSON or do they use existing code such as: www.json.org/java ?
|
 |
Ivan Krizsan
Bartender
Joined: Oct 04, 2006
Posts: 2194
|
|
Hi!
Personally, I have always used different kinds of libraries to help me with marshalling and unmarshalling JSON data. My favourite library is Jackson: http://jackson.codehaus.org/
Best wishes!
|
 |
leo donahue
Ranch Hand
Joined: Apr 17, 2003
Posts: 327
|
|
Is this considered a "web service"?
http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=Phoenix%20Arizonat&results=10
It returns XML. My idea of a servlet returning a JSON string is not much different.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
|
|
|
I use Google's gson library for JSON conversions.
|
 |
leo donahue
Ranch Hand
Joined: Apr 17, 2003
Posts: 327
|
|
|
google's gson worked the first time I passed a plain old Java object.
|
 |
 |
|
|
subject: Servlet JSON response
|
|
|