This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Services and the fly likes JSON Formatting with Jersey, Jackson, & json.org/java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "JSON Formatting with Jersey, Jackson, & json.org/java" Watch "JSON Formatting with Jersey, Jackson, & json.org/java" New topic
Author

JSON Formatting with Jersey, Jackson, & json.org/java

James Dekker
Ranch Hand

Joined: Dec 09, 2006
Posts: 215
Using Java 6, Tomcat 7, Jersey 1.15, Jackson 2.0.6 (from FasterXml maven repo), & www.json.org parser, I am trying to
pretty print the JSON String so it will look indented by the curl -X GET command line.

I created a simple web service which has the following architecture:

My POJOs (model classes):





Using a Utility Class, I decided to hard code the POJOs as follows:



My web service:



When I run this using:



I get this in my Eclipse's console:

{"father":"Joe","mother":"Jennifer","children":[{"name":"Jimmy","age":"12","gender":"male"}]}

But from the curl command on the command line (this response is more important):

"{\n \"mother\": \"Jennifer\",\n \"children\": [{\n \"age\": \"12\",\n \"name\": \"Jimmy\",\n \"gender\": \"male\"\n }],\n \"father\": \"Joe\"\n}"

This is similar to the response I was getting just using plain old Jackson, see this post.

Would appreciate it if someone could point me in the right direction.
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 614
have answered it to your original post.


All desirable things in life are either illegal, banned, expensive or married to someone else !!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSON Formatting with Jersey, Jackson, & json.org/java
 
Similar Threads
Got null response from webservice while calling an implementation method which has arguements in it
Unable to Produce JSON - javax.ws.rs.WebApplicationException: com.sun.jersey.api.MessageException
Send PUT to different RESTful webservice running on the same local Tomcat?
ArrayList is Picking Up Last Item During Iteration.
JSON Formatting with Jersey and Jackson