You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by "Justen Walker (JIRA)" <ji...@apache.org> on 2014/09/03 19:39:51 UTC

[jira] [Comment Edited] (OFBIZ-5751) Replace JSON Parser with proper library

    [ https://issues.apache.org/jira/browse/OFBIZ-5751?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14120129#comment-14120129 ] 

Justen Walker edited comment on OFBIZ-5751 at 9/3/14 5:39 PM:
--------------------------------------------------------------

I have experience with two JSON apis which are compatible with ASL 2.

My personal recommendation is to do the minimum work possible to get rid of the old JSON dependency.

h2. JSON.simple 
*My Recommendation*
[JSON.simple|https://code.google.com/p/json-simple/] (ASL 2.0)

High-performance library that sacrifices features for speed and robustness. Has no additional dependencies beyond JDK 1.2 and above.

It parses JSON into a set of JSON objects which also implement common collections api (Map and List) so its pretty easy to use and doesn't have overhead of defining your JSON schema as a POJO ahead of time.

h2. Jackson
[Jackson 2.x|http://wiki.fasterxml.com/JacksonInFiveMinutes] (ASL 2.0 or LGPL 2.1)

The library is very feature-rich.  It's useful if you want to convert JSON to/from Java Beans/POJO. it also supports the same kind of parsing JSON.simple does. It's annotation-driven and supports mix-ins. Features are a bit too numerous to list here.

---

I'm sure there are others worth investigating but I can't comment on them due to lack of experience working with them.



was (Author: justen_walker):
I have experience with two JSON apis which are compatible with ASL 2.

My personal recommendation is to do the minimum work possible to get rid of the old JSON dependency.

h2. JSON.simple 
*My Recommendation*
[JSON.simple|https://code.google.com/p/json-simple/] (ASL 2.0)

High-performance library that sacrifices features for speed and robustness. Has no additional dependencies beyond JDK 1.2 and above.

It parses JSON into a set of JSON objects which also implement common collections api (Map and List) so its pretty easy to use and doesn't have overhead of defining your JSON schema as a POJO ahead of time.

h2. Jackson
[Jackson 2.x|http://wiki.fasterxml.com/JacksonLicensing] (ASL 2.0 or LGPL 2.1)

The library is very feature-rich.  It's useful if you want to convert JSON to/from Java Beans/POJO.
It's annotation-driven and supports mix-ins. Features are a bit too numerous to list here.

---

I'm sure there are others worth investigating but I can't comment on them due to lack of experience working with them.


> Replace JSON Parser with proper library
> ---------------------------------------
>
>                 Key: OFBIZ-5751
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-5751
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework
>            Reporter: Justen Walker
>            Priority: Minor
>              Labels: json
>
> Recently I was bitten by the JavaCC JSON parser.  Apparently the folks developing JavaCC thought that encountering an unexpected token in the input stream should be treated like a StackOverflowError or OutOfMemoryError and derive from the Error class rather than Exceptions - guaranteeing that no sane try/catch block would be able to catch it (Since you aren't typically expected to catch [Errors|http://docs.oracle.com/javase/6/docs/api/java/lang/Error.html])
> A bit peeved by this design bug, I did some more investigation as to when this class was added and why. I discovered that this was added 4 years ago (February 10 2010) with the commit message admitting that - even though it seemed unneeded - it would later be extended to be more useful. 
> It has been 4 year since that commit and the code has not been touched. In that time (and perhaps even at that time) other production-ready libraries have been created for parsing JSON; some which are extensible and full featured as well those which are very simple and robust. (A list exists at [json.org|http://json.org/])
> I don't see a need to keep maintaining a home-rolled JSON parsing library inside the project that has to be built by everyone when other libraries exist that do the job better and are less likely to have these pitfalls (due to being actively developed).
> *References*
> - [Rev 908712 - 10 Feb 2010|https://fisheye6.atlassian.com/changelog/ofbiz?cs=908712]
> - [File History of JSON.jj|https://fisheye6.atlassian.com/browse/ofbiz/trunk/framework/base/src/org/ofbiz/base/json/JSON.jj]
> - [json.org (list of java libraries)|http://json.org/]



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)