| 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: 613
|
|
have answered it to your original post.
|
All desirable things in life are either illegal, banned, expensive or married to someone else !!!
|
 |
 |
|
|
subject: JSON Formatting with Jersey, Jackson, & json.org/java
|
|
|