JSON Arrray parsing with

11 Sep

I’m currently developing the backendservices for our new absenceplanner. We submit all data to a rest service (CustomRestService in the ExtLib). So this service should be able to parse an array of json data. The data has the following format:

“reqTitle”:”meine wohlverdienten ferien”,

To parse the stream in to a JsonJavaObject I’ve used:

JsonJavaFactory factory = JsonJavaFactory.instanceEx;
Reader r = request.getReader();
json = (JsonJavaObject) JsonParser.fromJson(factory, r);
String strMethod = json.getString(“method”);

It’s very easy to extract all properties. An object can also be accessed with json.getJsonObject(“name”) . But no arrays. There is no getter.

But, how did others (like the ExtLib programmers) solve this? With this question I’ve read the code of the “twitter parsing” in the sbt of the ExtLib. And I found the solution in the class, which guides me to the following code:


Object arrDates = factory.getProperty(json, “dates”);
for (Iterator<Object> itDate = factory.iterateArrayValues(arrDates); itDate.hasNext();) {

JsonJavaObject jsDate = (JsonJavaObject);
//-> here do all the funny stuff with the jsDate object.

Thanks to Philippe Riand (IBM) for sharing your code. Its so inspiring to read your code.


Posted by on September 11, 2012 in Java, XPages


Tags: , , , ,

6 responses to “JSON Arrray parsing with

  1. Jeff Byrd

    March 15, 2013 at 4:29 pm

    Thanks for posing this. Saved me a lot of time!

  2. Frank van der Linden

    June 19, 2013 at 2:05 pm

    It saved my day, thanks for this information

  3. Oliver Busse

    April 11, 2014 at 9:59 pm

    Argh, why didn’t I find this before struggeling with JacksonJSON?
    Thanks for sharing and thanks to me for finding it 😉

    • guedebyte

      April 11, 2014 at 10:02 pm

      🙂 I know that feeling. If you wanna produce JSON Output from obejct, you should also take a look at the XPagesToolkit

  4. corejavatraininginhyderabad

    May 2, 2017 at 2:38 pm

    Very nice and informative article. The information provided saved my time and was of great use. Thanks for posting this article. Keep posting.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: