open an object JSON in Java ( servlet ) -


i decree in separate folder of json file type. these files can not open them , eleborarli javascript through $ .getjson (). same thing can in java, or rather, can open .json in java , process function $ .getjson in javascript?

my json :

node1.json

{     "title": "risoluzioni problemi 1",     "id": "node1",     "radiolist": [{             "text": "possibile problema 1",             "value": "node2"         },         {             "text": "possibile problema 2",             "value": "node3"         },         {             "text": "possibile problema 3",             "value": "node4"         }     ] }            

to work json, javascript / jquery used:

$.getjson('node1.json', function (data){              createnextnodes(data);         }); 

everything works. same thing ajax requests server, question asked myself is, in jquery can open , edit files node1.json in servlet?

even better in java (servlets) function / method same thing $ .getjson () jquery?

in java can make below

public void parsejson(string path) {     jsonparser jsonp = new jsonparser();     try {         object obj = jsonp.parse(new filereader(path));         jsonobject jsono = (jsonobject) obj;         string title = (string) jsono.get("title");         string id = (string) jsono.get("id");          system.out.println(title);///or edit         system.out.println(id);//or edit         jsonarray array = (jsonarray) jsono.get("radiolist");         iterator<string> = array.listiterator();         while (it.hasnext()) {             object next = it.next();             system.out.println(next);//or edit         }      } catch (exception e) {         e.printstacktrace();     } } 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -