Hi All, We are in a process of evaluating the libraries to process JSON schema (read and write) and we found few libraries as listed below:
- Jackson [1] - JSON.simple [2] - Gson Based on the findings when comparing the GSON and Jackson [3], it seems Jackson has more complete support than Gson - Streaming (Streaming API) reading, writing, for ultra-high performance (or memory-limited) use cases - Tree model (DOM-like access),can convert between various models (tree <-> java object <-> stream) - Can use any constructors (or static factory methods), not just default constructor - Field and getter/setter access - Interoperability: can also use JAXB annotations, has support/work-arounds for common packages - Support for deserializing polymorphic types (Jackson 1.5),can serialize AND deserialize things like List correctly (with additional type information) When considering the JSON.simple[4], it is a simple Java library for JSON processing, read and write JSON data and it is full compliance with json specification. If we compare this with other two libraries [5], If we are dealing with both small and large schema files,neither Jackson nor GSON perform well across multiple files sizes as JSON.simple does. ( Jackson support well for large files only) If we consider the implementation for read JSON schema and generating the schema, below things can be highlighted - Jackson - We can use an ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) object and read the values of the fields in the schema (Tree Model) using fieldNames(), isObject(), isArray() etc and also can use methods like createArrayNode(), createObjectNode() in generating the JSON schema. - JSON.Simple - We can use JSONObject (org.json.simple.JSONObject) and JSONArray (org.json.simple.JSONArray) to read and write values to/from JSON schema AFAIU, implementation wise we can use either Jackson or JSON.simple and when comparing the performance it seems both are better than GSON But, when considering selecting the best library i feel JSON.simple would be better since it has following features -Full compliance with JSON specification and reliable -Provides multiple functionalities such as encode, decode/parse and escape JSON text while keeping the library lightweight -Flexible, simple and easy to use by reusing Map and List interfaces -Supports streaming output of JSON text - High performance - No dependency on external libraries Shall we proceed with JSON.simple? WDYT? [1] http://wiki.fasterxml.com/JacksonInFiveMinutes [2] https://code.google.com/archive/p/json-simple/ [3] http://stackoverflow.com/questions/2378402/jackson-vs-gson [4] https://code.google.com/archive/p/json-simple/ [5] http://blog.takipi.com/the-ultimate-json-library-json-simple-vs-gson-vs-jackson-vs-json/ Thanks, Sohani Sohani Weerasinghe Software Engineer WSO2, Inc: http://wso2.com Mobile : +94 716439774 Blog :http://christinetechtips.blogspot.com/ Twitter : https://twitter.com/sohanichristine
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev