PDA

View Full Version : more help with neted json/grids



merkelct
14 Oct 2008, 10:33 AM
So this is fairly simple I think and may have a quick fix for some one with a little more experience. I am trying to read this JSON output from service but I am having problems getting it to display in the grid
---------------------JSON------------------------

{
"gml:boundedBy":{
"gml:Box":{
"gml:coordinates":"-90.15928435058382,22.0 22.0,38.08512896968824"}},
"gml:featureMember":{
"iwfs:DDMS_PROFILE":{
"iwfs:OBJECTID":209,
"iwfs:POINT_LAT":38.08512896968824,
"iwfs:POINT_LON":-90.15928435058382,
"iwfs:TITLE":"Old French fort in IL",
"iwfs:TITLE_CLASSIFICATION":"U",
"iwfs:TITLE_PRODUCER":"USA",
"iwfs:DATE_CREATED":"2008-10-09",
"iwfs:DATE_POSTED":"2008-10-09",
"iwfs:FILEID":"http://12.187.20.148/gdtsfiles/",
"iwfs:SEC_CLASS_VALUE":"U",
"iwfs:SEC_OWNER_PRODUCER":"USA",
"iwfs:DESC_VALUE":"Location of the former French regeims military HQ in colonial IL.",
"iwfs:DESC_CLASS":"U",
"iwfs:DESC_OWNER_PRODUCER":"USA",
"iwfs:CREATOR_CLASS":"U",
"iwfs:CREATOR_OWNER_PRODUCER":"USA",
"iwfs:CREATOR_NAME":"Brian",
"iwfs:CREATOR_SURNAME":"Smith",
"iwfs:CREATOR_AFFILIATION":"NGA",
"iwfs:SUBJECT_COVERAGE_KEYWORD":"GEOINT",
"iwfs:GEOMETRY":{
"gml:Point":{
"gml:coordinates":"-90.15928435058382,38.08512896968824"}}}},
"gml:featureMember":{
"iwfs:DDMS_PROFILE":{
"iwfs:OBJECTID":192,
"iwfs:POINT_LAT":22,
"iwfs:POINT_LON":22,
"iwfs:TITLE":"Off",
"iwfs:TITLE_CLASSIFICATION":"U",
"iwfs:TITLE_PRODUCER":"USA",
"iwfs:DATE_CREATED":"2008-10-07",
"iwfs:DATE_POSTED":"2008-10-07",
"iwfs:FILEID":"192www.google.com",
"iwfs:SEC_CLASS_VALUE":"U",
"iwfs:SEC_OWNER_PRODUCER":"USA",
"iwfs:DESC_VALUE":"once a day",
"iwfs:DESC_CLASS":"U",
"iwfs:DESC_OWNER_PRODUCER":"USA",
"iwfs:CREATOR_CLASS":"U",
"iwfs:CREATOR_OWNER_PRODUCER":"USA",
"iwfs:CREATOR_NAME":"Chad",
"iwfs:CREATOR_SURNAME":"Sucks",
"iwfs:CREATOR_AFFILIATION":"ME",
"iwfs:SUBJECT_COVERAGE_KEYWORD":"Afghanistan",
"iwfs:GEOMETRY":{
"gml:Point":{
"gml:coordinates":"22.0,22.0"}}}}}Here is the simple code I am trying to read it into the grid with

final Panel panel = new Panel();
panel.setBorder(false);
panel.setPaddings(15);

final HttpProxy dataProxy = new HttpProxy("xml.json");
final RecordDef recordDef = new RecordDef(new FieldDef[]{
new IntegerFieldDef("iwfs:OBJECTID", "iwfs:OBJECTID"),
new StringFieldDef("iwfs:TITLE", "iwfs:TITLE"),
//new IntegerFieldDef("area", "area"),
//new IntegerFieldDef("population", "population"),
});
JsonReader reader = new JsonReader(recordDef);
reader.setRoot("gml:featureMember.iwfs:DDMS_PROFILE");
//reader.setTotalProperty("iwfs:OBJECTID");

final Store store = new Store(dataProxy, reader, true);
store.load();

ColumnModel columnModel = new ColumnModel(new ColumnConfig[]{
new ColumnConfig("Object ID", "iwfs:OBJECTID", 100, true),
new ColumnConfig("Ttile", "iwfs:TITLE", 75, true),

});

GridPanel grid = new GridPanel();
grid.setStore(store);
grid.setColumnModel(columnModel);
grid.setWidth(600);
grid.setAutoHeight(true);
grid.setTitle("Json Grid");
grid.setFrame(true);
grid.stripeRows(true);
grid.setIconCls("grid-icon");
panel.add(grid);

RootPanel.get().add(panel); Right now I get no errors but there is nothing in the grid I have checked height and width and that seems to be okay any assitance would be greatly appreciated
Thanks in advance

Corey

premlk
14 Nov 2008, 4:00 PM
In your code you are setting the root to point to object. This is not supported. You need the root to point to object array..

refer this :
http://gwt-ext.com/docs/gwtext2/com/gwtext/client/data/JsonReader.html#setRoot(java.lang.String)




Jason:
"gml:featureMember":{
"iwfs:DDMS_PROFILE":{
JsonReader reader = new JsonReader(recordDef);
reader.setRoot("gml:featureMember.iwfs:DDMS_PROFILE");