I am trying to create a REST web service in Jersey. I want to get and select JSON objects from Java classes, for example:
@XmlRootElement public class Book { public String code; public HashMap<String, String> names; }
This should be converted to JSON as follows:
{ "code": "ABC123", "names": { "de": "Die fabelhafte Welt der Amelie", "fr": "Le fabuleux destin d'Amelie Poulain" } }
However, I cannot find a standard solution for this. It seems that everyone is implementing their own wrapper solution . This requirement seems extremely basic to me; I canβt believe that this is a generally accepted solution for this, especially since Jersey is really one of the most interesting parts of Java.
I also tried upgrading to Jackson 1.8, which only gives me this, which is extremely inconvenient for JSON:
{ "code": "ABC123", "names": { "entry": [{ "key": "de", "value": "Die fabelhafte Welt der Amelie" }, { "key": "fr", "value": "Le fabuleux destin d'Amelie Poulain" }] } }
Are there any suggested solutions for this?
java json rest jackson jersey
samy-delux Apr 26 '11 at 18:22 2011-04-26 18:22
source share