Here is my desired result
{"node":{"type":"community","field_incentives":{"und":[{"value":"fun"},{"value":"nice"}]},"field_community_email":{"und":[{"value":"some@one.com"}]}}}
Here is my code, but it does not seem to generate the result above. If there is a better and easier way to do this, please let me know. Thanks
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.writeEndObject(); g.close();
java json jackson
Andy
source share