codenameone - Codename One - How to Store an Array of JSON data in Persistent Memory and Read it Back -


i have json data receive response after sending json request. store data in persistent storage memory or file , read later , display in on screen dropdown list. appreciate if knows how in codename one.

    {    result_code=0.0,    data=   [       {          id=1,          title=afghanistan       },       {          id=2,          title=albania       },       {          id=3,          title=algeria       },       {          id=4,          title=andorra       },       {          id=5,          title=angola       },       {          id=6,          title=antigua , barbuda       },           ],    message=ok      } 

i did small test (y)

string x = "{result_code=0.0,data=   [{id=1,  title=afghanistan   },      {         id=2,         title=albania      },      {         id=3,         title=algeria      },      {         id=4,         title=andorra      },      {         id=5,         title=angola      },      {         id=6,         title=antigua , barbuda      },       ],   message=ok     }"; storage.getinstance().writeobject("abcd.txt", x); object rawstring = storage.getinstance().readobject("abcd.txt"); jsonobject jsonobject = new jsonobject(rawstring.tostring()); jsonarray data = (jsonarray) jsonobject.get("data"); double resultcode = double.valueof(jsonobject.getdouble("result_code")); string message = jsonobject.get("message").tostring();  // todo: json parsing jsonobject firstobjectfromarray = data.getjsonobject(0); // todo: somestuff in loop , put combobox? firstobjectfromarray.get("id"); firstobjectfromarray.get("title"); 

edit: combobox component speaking of?


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -