*
The moose likes Other Open Source Projects and the fly likes How to format this using Jackson JSON? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "How to format this using Jackson JSON?" Watch "How to format this using Jackson JSON?" New topic
Author

How to format this using Jackson JSON?

Ong Vua
Ranch Hand

Joined: Jan 24, 2008
Posts: 59
This is the desired output

{"node":{"type":"community","field_incentives":{"und":[{"value":"fun"},{"value":"nice"}]},"field_email":{"und":[{"value":"some@one.com"}]}}}

Here's my code.

ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
JsonFactory f = new JsonFactory();
JsonGenerator g = f.createJsonGenerator(outputStream);
g.writeStartObject();
g.writeObjectFieldStart("node");
g.writeStringField("type", "community");
g.writeObjectFieldStart("field_incentives");
g.writeFieldName("und");
g.writeStartArray();

???I don't know how to make [{"value":"fun"},{"value":"nice"}]
g.writeEndArray();
g.writeObjectFieldStart("field_email");
g.writeFieldName("und");
g.writeStartArray();

???
g.writeEndArray();
g.writeEndObject();
g.close();

Here's the output

{"node":{"type":"community","title","field_incentives":{"und":[],"field_email":{"und":[]}}}}

Thanks

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to format this using Jackson JSON?
 
Similar Threads
How to access byte array web method
Serialize an object to db2
ByteArrayInputStream problem
Tool tip is not coming when we displayed a graph in JSP
opening a pdf file created by jasper in client side