I have a JSF grid type component where each cell is individually editable and the data for each cell is contained in a POJO called DataObject(DO) . The structure of DO is like this :
public class DO {
//Id should be the coordinate. eg x@y . x is the row position and y is the column position
private String id;
//This is value that goes to the client after applying formatter
private Object value;
//flag to indicate whether the cell will be disabled
private boolean disabled;
//flag to indicate whether the cell will be rendered
private boolean rendered=true;
//Editor type for the cell
private String editorType;
}
So basically id
field identifies the cell position(row and column) in the grid.
Now in our case we can have a 1000 row X 100 column grid where the grid itself is sparsely populated initially meaning that most of the cells do not contain any DO intially. So about 30% of those cells will contain data and the rest will not contain any data. I need to pass the data in JSON format from the server to the client javascript via ajax. The idea is to iterate through the collection of DO's and construct the JSON String .
So the JSON for a grid that has data for two cells would look something like this :
{
id1 : {
editorType:'InputEditor',
value:'1234123',
disabled:'false',
rendered:'true'
},
id2 : {
editorType:'SomeCustomEditor',
value:'23456',
disabled:'true',
rendered:'true'
}
}
What existing JSON Java library can I use here to produce this output JSON in the most efficient way ? Any example code will help here .