Skip to content

replace json.org library with own wrapper #773

Closed

Description

@karussell

Currently we use a json libary with a potential ugly license in web module (The software shall be used for good, not evil.). Others don't like it too. Android has a Apache licensed version of it here claiming that: "this class was written without inspecting the non-free org.json sourcecode"

So we should look into alternatives to replace this.

Also for several tasks we need a json parser in the core in the future. Such a parser should be fast, small, actively maintained, usages according to this, simple to use for basic configuration reading stuff, available on maven central and the Apache License is preferred. Also Java 7 is required for now, reading into POJOs would be good but not required.

Probably a lot simpler would be if we pick one for now, create a simple interface and then could switch afterwards.

Activity

  1. karussell commented on Aug 22, 2016

    @karussell
    MemberAuthor

    The size is not that important as on Android side one could use ProGuard (cherry picking the classes), on server side it does not matter and for iOS we probably need a different implementation.

    Hmmh, strange. Tested the additional size e.g. with gson and jackson and it added just 20kb to core although fully functional (serializing&deserializing) and original jars are like >200KB ... probably the jar-with-dependencies plugin already does cherry picking? No ... I just made a build mistake and the increase is as expected. Maven shade would be an option with minimizeJar=true

  2. devemux86 commented on Aug 22, 2016

    @devemux86
    Contributor

    Well Gson has been more than good all this time. 👍

    Also note that Android has a base JSON API integrated.

  3. karussell commented on Aug 22, 2016

    @karussell
    MemberAuthor

    Thanks! Looks like they just copied the JSON lib we are currently using. Despite the license thing.

  4. karussell commented on Aug 22, 2016

    @karussell
    MemberAuthor

    moshi looks even more streamlined (100KB) and is very similar to gson

  5. devemux86 commented on Aug 22, 2016

    @devemux86
    Contributor

    Does it require also Okio (75KB)?

  6. karussell commented on Aug 22, 2016

    @karussell
    MemberAuthor

    Ah, indeed. Still looks somehow cleaner: https://github.com/square/moshi#borrows-from-gson and okio is something we potentially need for okhttp at some point when replacing Downloader.

  7. karussell commented on Aug 22, 2016

    @karussell
    MemberAuthor

    But still investigating and jackson seems to be more widespread ... maybe we should wait for the JDK to use some standard json parser? There is already a JSR for it: https://jcp.org/en/jsr/detail?id=353

    Potentially the interface is the best idea where we can easily replace the implementation depending on the underlying platform

  8. devemux86 commented on Aug 22, 2016

    @devemux86
    Contributor

    Many comparisons online for the two of them - Gson vs Jackson. 😄

    maybe we should wait for the JDK to use some standard json parser? There is already a JSR for it: https://jcp.org/en/jsr/detail?id=353

    When it'll be included, in Java 9 or 10? Also then Android is another story.

  9. devemux86 commented on Aug 27, 2016

    @devemux86
    Contributor

    @karussell can the json stuff be in another module, for not loading core with dependencies?

  10. karussell commented on Aug 27, 2016

    @karussell
    MemberAuthor

    I'm not sure about this as we need this as core feature. Probably we can use normal classes but abstracting this away might be too much work - not sure if it is worth the effort.

    BTW: see this json stuff implemented in #781

  11. karussell commented on Sep 6, 2016

    @karussell
    MemberAuthor

    Now #781 is merged. Also I found that something called (a bit misleading if you ask me) JSON-P is already standardized through JCP (javax.json), already present in JavaEE7 and documented in latest javamagazine

  12. karussell commented on Sep 17, 2016

    @karussell
    MemberAuthor

    Ok, we now have a simple JSON parsing/writing module and can extend this. In the core module we should probably not use JSON but instead use simple POJOs. Also the XML creation should be probably moved out of the core. So the remaining task is to use our JSON parser/writer interface for all purposes and get rid of the org.json dependency.

  13. changed the title [-]json library for core[/-] [+]replace json.org library with own wrapper[/+] on Sep 17, 2016
  14. devemux86 commented on Sep 17, 2016

    @devemux86
    Contributor

    @karussell well defined course of actions! 👍

  15. karussell commented on Nov 17, 2016

    @karussell
    MemberAuthor

    As we have managed to avoid using the JSON lib in the core we can also move to the more standard and more powerful jackson library, probably. Not sure. E.g. #855 adds jackson already as test dependency for csv parsing.

  16. michaz commented on Apr 28, 2017

    @michaz
    Member

    The original goal, getting rid of the json.org library, is now accomplished. We still use gson in reader-json for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions