jsonarray

Create a JSON Array using Java

Hi I want to create a JSON array. I have tried using: JSONArray jArray = new JSONArray(); while(itr.hasNext()){ int objId = itr.next(); jArray.put(objId, odao.getObjectName(objId)); } results = jArray.toString(); Note: odao.getObjectName(objId) retrieves a name based on the "object Id" which is called objId However I get a v...

parse Java JSONArray with jquery.parseJSON()

Hi Guys, at the moment I'm parsing the string with eval()-method and it works fine, but want to parse it with the native JSON methods of a browser. Is there good way to parse the string with jquery.parseJSON() or with any other jQuery method to an array of javascript objects? The string looks like [ { "title": "01 Books",...

Targetting a specific part of json array, if present create table.

Hi All, I have a complex json array which I want to target a specific line/string and if present then add a small table to web page... This is the array { "coastalWarnings":[{ "loc":"ABEL", "warn":"GALE" },{ "loc":"CASTLEPOINT", "warn":"STORM" },{ "loc":"CHALMERS", "warn":"GALE" },{ "loc":"CHATHAM ISLANDS", "warn"...

json official java api : JSONArray of JSONObjects

Salaam, Using json.org API, we can easily convert a map to a JSON object : Map<String, String> carta = new Map<String, String>(); carta.put( "id", "123"); carta.put( "Planet", "Earth"); carta.put( "Status", "getting dirty"); JSONObject json = new JSONObject(); for(Iterator<String> it=input.keySet().iterator(); it.hasNext();){...

json changes the order of elements

Hello, I am trying to send a list of objects from an android mobile phone app to a j2ee webserver. I create json objects and then put the objects into an jsonarray(in an order) and then send it. I am able to receive the jsonarray on the server, obtain the objects individually too, but the order of how I inserted the objects into the jso...