JSON-lib is a java library for transforming beans, maps, collections,
java arrays and XML to JSON and back again to beans and DynaBeans.
It is based on the work by Douglas Crockford
in http://www.json.org/java.
The following tables sumarizes the types conversion between java and
javascript:
| JSON | Java | |
|---|---|---|
| string | <=> | java.lang.String, java.lang.Character, char |
| number | <=> | java.lang.Number, byte, short, int, long, float, double |
| true|false | <=> | java.lang.Boolean, boolean |
| null | <=> | null |
| function | <=> | net.sf.json.JSONFunction |
| array | <=> | net.sf.json.JSONArray (object, string, number, boolean, function) |
| object | <=> | net.sf.json.JSONObject |
function type from javascript is not part of the JSON
format "officially" (please refer to http://www.json.org)
but it is supported as well.
Json-lib comes in two flavors, depending on the jdk compatibility. json-lib-x.x-jdk13 is compatible with JDK 1.3.1 and upwards. json-lib-x.x-jdk15 is compatible with JDK 1.5, includes support for Enums in JSONArray and JSONObject. Please reffer to the appropriate javadoc links available in the project menu.
Json-lib requires (at least) the following dependencies in your classpath: