java - How to use JSON file using clientbundle in gwt -


i have static json file , want access in gwt code. custom-report.json file in client package of project. adding in clientbundle , trying access error

public interface appbundle extends clientbundle {      @source("custom-report.json")     public textresource jsondata();     public static final appbundle instance = gwt.create(appbundle.class);  } 

to use in code, doing:

appbundle.instance.mystyle().ensureinjected();  jsonobject obj = (jsonobject) parser.parse(new filereader(appbundle.instance.jsondata().gettext())); 

this gives me compilation error

[error] line 29: no source code available type org.json.simple.parser.jsonparser; did forget inherit required module? 

i not sure if correct way use json file in gwt.

you need use com.google.gwt.json.client.jsonparser provided gwt instead of org.json.simple.parser.jsonparser.

jsonvalue value = jsonparser.parse(json); jsonobject productsobj = value.isobject(); jsonarray productsarray = productsobj.get("products").isarray(); 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -