aspose file tools
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
Register / Login


JavaRanch » Java Forums » Products » Other Open Source Projects
Reply 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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to format this using Jackson JSON?
 
Similar Threads
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
How to access byte array web method