If you have ever tried to work with JSON in an Eclipse plugin you know it is not strait forward.  One of the easiest ways to work with JSON is to use the libraries from json.org.  However if your working with JSON inside of Notes 8.5.2 or later, there is actually a library built into Notes you can use.  Your plugin will need to have a dependency on com.ibm.commons.  In this plugin there are several classes you can use to work with JSON.  The Javadoc for the APIs can be found here.  Here is a sample class which will parse a string of JSON into a Java object which you can in turn use to get values from.  As JSON becomes more and more popular with web services, having libraries to deal with JSON objects when your not using Javascript is critical.

4 comments on “Useful Library For Parsing And Creating JSON In Notes

  • And you should avoid to use the org.json classes from http://www.json.org , although they may look very easy to use. The JSONObject.toString() is VERY bad for large amounts of data, because it concatenates the single string values using “+” instead of a StringBuffer in a lot of cases. That can really blow up server memory.
    Prefer to stream JSON in and out using the com.ibm.commons utility classes or an open source project like Jackson instead ( http://jackson.codehaus.org/ ) or if you really want to use org.json , spend some time to optimize their code.

    • Even I had a tough time finding out these classes. It’s not very obvious by the plugins name that it would have this functionality. That’s why it makes for a good blog post 😉

Leave a Reply

Your email address will not be published. Required fields are marked *