I\'m using Jackson to build a custom JSON object. Is the correct way of going about this?
It seems to work well (and the output is correct) but I may be missing the way
Just a suggestion, it would be easier to directly deal with simple datatypes and serialize those to JSON and back using Jackson ObjectMapper, rather than deal with raw Jackson Treemodel
So in your example, you could create a structure of the following type:
class AaData{
private List rowList = new ArrayList();
..
class ARow{
String ounces;
String revolutions;
..
Then the following will generate the appropriate json for you:
StringWriter sw = new StringWriter();
JsonFactory jf = new JsonFactory();
ObjectMapper m = new ObjectMapper();
m.writeValue(sw, aaData);
System.out.println(sw.toString());