IMPORTANT: Per accedir als fitxer de subversion: http://acacha.org/svn (sense password). Poc a poc s'aniran migrant els enllaços. Encara però funciona el subversion de la farga però no se sap fins quan... (usuari: prova i la paraula de pas 123456)

org.json

Recursos:

API javadocs

http://www.json.org/javadoc/

Codi font

https://github.com/douglascrockford/JSON-java

Altra documentació

http://www.json.org/java/index.html

Exemples


    package com.concretepage;
    import org.json.JSONArray;
    import org.json.JSONException;
    import org.json.JSONObject;
     
    public class JSONTest {
    public static void main(String... args) throws JSONException{
    final JSONObject res = new JSONObject();
    //adding value in JSON object
    JSONArray jarray= new JSONArray();
    for(int i=0;i<3;i++){
    JSONObject ob = new JSONObject();
    ob.put("k1"+i, "v1"+i);
    ob.put("k2"+i, "v2"+i);
    jarray.put(ob);
    }
    res.put("res", jarray);
    System.out.println("structure of created json object:"+res);
    //retrieving value from JSON object element wise
    System.out.println("retrieving value from JSON object element wise");
    JSONArray output= res.getJSONArray("res");
    for(int i=0;i<output.length();i++){
    JSONObject ob= output.getJSONObject(i);
    System.out.print(ob.get("k1"+i));
    System.out.println(ob.get("k2"+i));
    }
    }
    }

Sortida:

structure of created json object:{"res":[{"k20":"v20","k10":"v10"},{"k11":"v11","k21":"v21"},{"k22":"v22","k12":"v12"}]}
retrieving value from JSON object element wise
v10v20
v11v21
v12v22

Altres llibreries

llista extreta de:

http://www.json.org/json-es.html

Llista:

   org.json.
   org.json.me.
   Jackson JSON Processor.
   Json-lib.
   JSON Tools.
   Stringtree.
   SOJO.
   Jettison.
   json-taglib.
   XStream.
   Flexjson.
   JON tools.
   Argo.
   jsonij.
   fastjson.
   mjson.
   jjson.
   json-simple.
   json-io.
   JsonMarshaller.
   google-gson.
   Json-smart.
   FOSS Nova JSON.
   Corn CONVERTER.

Vegeu també

Enllaços externs