aspose file tools*
The moose likes Web Services and the fly likes JSON Formatting with Jersey, Jackson, & Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "JSON Formatting with Jersey, Jackson, &" Watch "JSON Formatting with Jersey, Jackson, &" New topic

JSON Formatting with Jersey, Jackson, &

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), & 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:


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: 613
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:
subject: JSON Formatting with Jersey, Jackson, &
Similar Threads
JSON Formatting with Jersey and Jackson
ArrayList is Picking Up Last Item During Iteration.
Send PUT to different RESTful webservice running on the same local Tomcat?
Got null response from webservice while calling an implementation method which has arguements in it
Unable to Produce JSON - com.sun.jersey.api.MessageException