Putting Domino's JSON to Use

So, we now know that Domino 7.0.2 includes the ability to output JSON for a view in the same way it's been creating XML for years. But how good is it? Personally I've always found the DXL for ?ReadViewEntries fairly useless due to its odd structure. Well, I'm happy to report that, while the JSON output is a "similar" structure, we can actually use the data as is.

Note that this JSON output isn't supported by Domino 7 and is likely to change format before it ships with Domino 8. Worth bearing in mind if you're thinking of coding with it.

This morning I quickly knocked together a proof of concept page that showed how, using a combination of the data from ?ReadViewEntries and the design from ?ReadDesign it's possible to script a view-like table on a page. The table columns are sized in proportion to the backend view, columns have the correct title and even the alternate row colour is inherited.

You can see the results here.

There are some odd things about the Domino JSON output. For example the array that contains all rows is called viewentry rather than viewentries. Although it's likely to change it's good to know this is going to be a feature and, most importantly, we'll actually be able to use it!


    • avatar
    • Gerry Shappell
    • Thu 25 Jan 2007 09:00 AM

    Thanks for the example...would you use this method just as a way of getting a better handle on layout and presentation as compared to a regular view? Or do you have any examples on why developers should use this?


    • avatar
    • Jake Howlett
    • Thu 25 Jan 2007 09:15 AM

    Hmm. Not sure I'd use it to create a table of a view like the example. Not a practical example by any means.

    This JSON view stuff is exciting as it makes it much easier to work with AJAX and Domino. We can get view entries from Domino in JSON format *without* messy agents AND we can use extra URL parameters like &Startkey= to really narrow down "search" results.

    Lots of other uses to. Such as pagination of views. In conjunction with Jack Slocum's Grid it would be really nice!

    • avatar
    • Gerry Shappell
    • Thu 25 Jan 2007 09:31 AM

    Thanks for the usage examples and link!

    • avatar
    • Axel Janssen
    • Thu 25 Jan 2007 03:23 PM

    I actually find the ?readViewEntries stuff interesting for integration.

    I have some java code (but this is possible with other languages too) which downloads and parses the ?ReadViewEntries from some forums on notes net with a sax parser and writes all the information in documents of a notes database. It actually also downloads the body of the postings which is admitedly not in the ?ReadViewEntries.

    At my job we are using bugzilla. From that system I also get data in xml form. I can again download and parse that data on a scheduled basis and replicate it in a notes database where I can add some extra-functionality like giving people the chance to assign a business value and estimated costs to the bug entries for prioritizing. Thats not ?readViewEntries, but the same idea.

    • avatar
    • Fabio
    • Fri 26 Jan 2007 10:50 AM

    You are the best !!!

    grande Jake . :-)

    • avatar
    • Mark C
    • Mon 29 Jan 2007 11:52 AM

    Has anyone put this to use? I'm trying to stuff the json (from an ajax call) and am not having much success. Looking through one of the debugging tools, I see \n in front of the json code:

    "{\n"@toplevelentries": 11,\n"@rangeentries": 2,\nviewentry: [\n{\n"@position": '9',\n"@unid": 'CF57E86AE56..."

    Any ideas

    • avatar
    • Jake Howlett
    • Mon 29 Jan 2007 11:53 AM

    Mark. \n is a newline in JavaScript. Is it causing your problems?

    • avatar
    • Mark C
    • Mon 29 Jan 2007 12:22 PM

    Yes, it was. I'm not sure who or what was inserting the newline char. I'm a little weak at advanced JS. Here is how I got it to work:

    var pos = "";

    var myjson = xmlHTTP.responseText ;

    otherjson = eval("(" + myjson+ ")");

    view["data"]=otherjson ;

    var documents= view["data"].viewentry ;

    for (var i=0; i<documents.length; i++)


    alert('in loop: ' )

    pos += documents[i].entrydata[1].text[0] ;


    $("viewtable").innerHTML = pos ;

    So, per wikipedia, I ran an eval on what was returned back to me. I then modifed your example to point view["data"] to the eval return, rather than what was returned from Domino. I'm developing in 7.0.2 and FF

    Any ideas?

    • avatar
    • Mark C
    • Mon 29 Jan 2007 12:25 PM

    BTW, in case your source didn't tell you, they are changing the json outputformat in 8. They are removing the @ from the front of the name since JS doesn't allow @ to be the first character.

    So whatever works now may need to be revisited when Domino 8 is installed.

    • avatar
    • Jake Howlett
    • Mon 29 Jan 2007 03:54 PM

    Mark. I see now. My code didn't need the eval() call as all the JSON code was in-line and so already treated as a JavaScript object. Didn't think to mention the eval(), which is needed when the JSON is fetched from Domino as plain text.

    • avatar
    • Mark Vincenzes
    • Tue 30 Jan 2007 08:30 AM

    @Mark C - there are no plans to remove the @ for version 8.

    One of my previous posts described the changes in 8.

    FYI, I am a member of the IBM Domino Web Server development team.

    • avatar
    • Mark C
    • Tue 30 Jan 2007 09:49 AM

    To Mark V. I may have misunderstood the Leveraging AJAX Frameworks to Build IBM Lotus Domino Web Applications presentation, but I was pretty sure the speaker mentioned that they were going to remove the @ from the "@position": '1', "@unid": '211F916D90F4425E8625726F0058B298', ... type elements.

    I will follow up with the speakers

    • avatar
    • Boyzl
    • Fri 9 Feb 2007 05:52 AM

    Hi everyone,

    I use JSON responses on Domino 6 but have a problem. Anyone has an idea how to properly include 'charset' or 'codepage' setting in header? Something like Print "Content-Type:text/plain charset:'windows-1250'"?

    I need it cause I want to return text with national characters by means of JSON object.


    regards from Slovenia,


    • avatar
    • Jake Howlett
    • Fri 9 Feb 2007 06:02 AM

    Boyzl. Try:

    Print "Content-Type:text/plain; charset:windows-1250"

    Note the semicolon and the unquoted charset name!

  1. The output format in release 8.0.2 is still the same, with @. Compared to the JSON of 7, the JSON of 8 now starts with @timestamp, next is @toplevelentries. In 7, it starts with @toplevelentries.

Your Comments


About This Page

Written by Jake Howlett on Thu 25 Jan 2007

Share This Page

# ( ) '


The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social

About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »


Here are the external links posted on the same day.

More links are available in the archive »

More Content