Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
James Dekker
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 642
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
have answered it to your original post.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic