Domino on Linux/Unix, Troubleshooting, Best Practices, Tips and more ...

alt

Daniel Nashed

Pretty-Printing JSON in Notes Client and Domino

Daniel Nashed – 26 July 2024 19:07:35

The Lotus Script class for reading and writing JSON is that easy. There are not many examples and some functionality is missing.

JSON can be either condensed without any new lines and indentation.
That's great when you use it for back-end processing or REST services.

Why is pretty printing important

But in some cases you need pretty formatted JSON. Specially when you want to maintain it manually and extend it. For example for Domino OTS JSON files :-)
When you use JSON based configuration pretty printed JSON is very helpful.

Condensed JSON is also difficult to check into Git.
Everything looks modified when it is a single line.

I am building multiple applications for different use cases and don't want external Libs like the famous JQ command line.
ChatGPT wasn't really helpful in this case, because, it always suggested code with Java classes we don't have in Notes/Domino.

Here is how to get it working out of the box with Java

So I asked the crowd in the OpenNTF Discord development channel.

After some discussions Jesse Gallagher came up with a solution based in Java libs Notes/Domino has included.
It's pretty simple once you know what to look for as you can see in this blog post --> https://frostillic.us/blog/posts/2024/7/26/pretty-printing-json-in-the-desktop-notes-client-and-domino.


AHA idea to enhance Lotus Script

This is still a work-around for me and it would be good to have JSON Pretty Printing in Lotus Script.
So I created an AHA idea you could vote for if you find it important --> https://domino-ideas.hcltechsw.com/ideas/DDXP-I-1287.

It would be small change in the back-end which would help to have it working on client platforms which have no Java support.

This is really a great example of the community working together and you will see an application soon leveraging this functionality.
I have already an agent to generate OTS JSON from a database and dump it to a file.

Thanks to Jesse again for jumping in and coming up with this solution.

-- Daniel



Links

    Archives


    • [HCL Domino]
    • [Domino on Linux]
    • [Nash!Com]
    • [Daniel Nashed]