I need to conver java array object to JSON, i am using jackson for this. I can only think that for every field name i have to iterate from the array which means i have to iterate the same array object for each field. Is there any efficient way of doing it?
JsonGenerator jGenerator = jfactory.createJsonGenerator(out);
jGenerator.writeStartObject();
jGenerator.writeFieldName("images");
jGenerator.writeStartArray();
for(int i=0; i < topicBean.getTopicVOArray().length; i++){
jGenerator.writeString(topicBean.getTopicVOArray()[i].getBody());
}
for(int i=0; i < topicBean.getTopicVOArray().length; i++){
jGenerator.writeString(topicBean.getTopicVOArray()[i].getTopicGuid()());
}