public void writeToJsonGenerator ( final JsonGenerator gen ) throws IOException { // writes '{eventName:<name>,payload:{<data>}}' --it's kind of silly but ultimately inconsequential to nest them like this. gen . writeStartObject ( ) ; gen . writeStringField ( "eventName" , eventName ) ; gen . writeFieldName ( "payload" ) ; /* Note: output format used depends completely on generator we are being passed * and NOT on which mapper we use -- mappers are format independent and rely * on underlying JsonParser/JsonGenerator for low-level handling. */ getObjectMapper ( ) . writeTree ( gen , root ) ; gen . writeEndObject ( ) ; }
having to know all the events ahead of time .