| Author |
JSON Formatting with Jersey and Jackson
|
James Dekker
Ranch Hand
Joined: Dec 09, 2006
Posts: 215
|
|
Using Java 6, Tomcat 7, Jersey 1.15, Jackson 1.9.9, 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:
MyWebService:
Produces:
What I need to do is have it produce it in a more legible manner:
Just am seeking a way to implement so it can display some type of formatting with indentation / tabs.
Would be very grateful if someone could assist me.
Thank you for taking the time to read this.
|
 |
Praful Thakare
Ranch Hand
Joined: Feb 10, 2001
Posts: 613
|
|
have you tried any json libraries ?
1) googles json lib
2) JSON try toString method from this lib.
-P
|
All desirable things in life are either illegal, banned, expensive or married to someone else !!!
|
 |
James Dekker
Ranch Hand
Joined: Dec 09, 2006
Posts: 215
|
|
Praful,
Thanks for the response!
When I tried this:
Using the curl command in Linux (this is my actual web service client):
This is the response I got:
{"children":[{"age":"12","gender":"male","name":"Jimmy"}],"father":"Joe","mother":"Jennifer"}
Doesn't seem like anything happened...
Here are the dependencies listed in my pom.xml file:
Does anyone know what I am possibly doing wrong?
|
 |
Praful Thakare
Ranch Hand
Joined: Feb 10, 2001
Posts: 613
|
|
I have not used fasterxml.jackson so no idea about it, try this
NOTE:- Retrun Type is String now
I get following output
Also, are you sure you paste correct code? I checked the online API of fasterxml and there is nothing like SerializationConfig.Feature.INDENT, it is SerializationConfigFeature.INDENT
-P
|
 |
 |
|
|
subject: JSON Formatting with Jersey and Jackson
|
|
|