Here’s what I’m trying to do:
First of all, the code I’m working with is passed a JSON string that was obtained by a call to RequestBuilder’s sendRequest function. I’d like to use JsonReader or JsonLoadResultReader to work with the contents of that JSON string, but your Json Grid demo shows a situation in which the RequestBuilder object is included in an HttpProxy object that in turn is used by a BaseListLoader object to get the JSON string and store it in a ListStore object without exposing the JSON string. I don’t understand how to use the constructor and other functions of the JsonReader class when I already have a JSON string that I want to store the contents of in the same way as is done in the Json Grid example.
So my first question is, is it possible to pass a JSON string in to a JsonReader object in order to get its contents into a ListStore, and if so, how?
Suppose my JSON string looks like this:
and I want to put the data that I obtain into a grid that has columns named “Name”, “At Bats”, “Hits” and “Batting Average”. The values in the “Name” column should be firstName + “ “ + lastName, and the values in the “Batting Average” column should be hits / atBats.
My second question is, What is the best way to map the data from the JSON string to the grid columns in a case like this where some conversion is needed? Should I define a ModelType object whose fields match those of the JSON string and a ColumnModel whose list of ColumnConfig objects matches the columns of the grid and then map them somehow after having read the JSON string into a ListStore using that ModelType in the JSonReader? If so, what classes are there that support this kind of mapping? Or is it better to read the JSON string contents straight into a data structure that represents the columns of the grid -- And if so, how do you do that?
Thanks for your help.