203 Lotus blogs updated hourly. Who will post next? Home | Blogs | Search | About 
 
Latest 7 Posts
OpenNTF on Twitter
Fri, Nov 17th 2017 201
OpenCode4Connections Contest Winners
Thu, Oct 19th 2017 2
OpenNTF Board of Directors
Thu, Sep 28th 2017 4
Say hello to "OpenCode4Connections.org"
Thu, Sep 14th 2017 7
OpenNTF Board of Directors - Call for Nominations
Wed, Aug 23rd 2017 4
Social SDK - Bring it to the next stage
Mon, Apr 3rd 2017 3
OpenAPI Specifications for Freebusy and Calendar available on OpenNTF's Github account and SmartNSF Beta 2 released
Sat, Mar 11th 2017 1
Top 10
OpenNTF on Twitter
Fri, Nov 17th 2017 201
On OpenNTF: Script Portlet Samples for IBM WebSphere Portal
Wed, Apr 9th 2014 8
Learn, share and collaborate - The monday at IBM Connect is YOUR Day
Mon, Jan 16th 2017 8
On OpenNTF: RSS Sample for IBM Digital Data Connector in WebSphere Portal
Fri, Jun 6th 2014 7
Say hello to "OpenCode4Connections.org"
Thu, Sep 14th 2017 7
IBM Connect 2014 - BP207 - Don’t Reinvent the Wheel - (Re)use Open Source Software From OpenNTF
Tue, Feb 4th 2014 6
Wizard to create XPages based Mobile Apps
Wed, Feb 5th 2014 6
2000 XPages Questions on StackOverflow
Wed, Feb 19th 2014 6
On OpenNTF: Change Tracking for IBM Domino Directory
Tue, May 20th 2014 6
Project Spotlight: OpenLog, XPages OpenLog Logger, XLogBack
Wed, May 25th 2016 6


Project Spotlight: JsonBeanX and Jackson4XPages
Twitter Google+ Facebook LinkedIn Addthis Email Gmail Flipboard Reddit Tumblr WhatsApp StumbleUpon Yammer Evernote Delicious
Paul Withers    

A search of OpenNTF projects for the term JSON will return a number of projects over a long period of time. JSON has long been a key data interchange format, being language independent and not requiring a fixed agreed schema. It is this reason in particular that has led to it overtaking SOAP as a data transfer mechanism, enabling microservices to be built and further developed without breaking existing interactions. Anything that delivers JSON data can of course be access via (Client-Side) JavaScript and, if client-side is your preferred approach and you're only interested in consuming and not delivering JSON data on request, there will be standard out-of-the-box approaches that you can leverage.

But for server-side approaches - whether for consuming or delivering on external request - the options available are various. When I initially developed XPages Help Application some years ago, the approach I used was to manually construct strings of JSON data. But the Domino platform has opened up tools for leveraging this, particularly in the 9.0.x timeframe with Domino Access Services and the com.ibm.commons.util.io.json package. Domino Access Services provide out-of-the-box basic CRUD APIs to access Domino databases, including Mail and Calendar. But DAS does not manage validation or manipulation of data types. The com.ibm.commons.util.io.json package provides low-level Java APIs to read to and write from JSON objects, and of course it is also via Server-Side JavaScript, since SSJS classes are actually Java classes under the hood. But every element of the JSON data needs reading or writing individually, which can be verbose.

Following on from his session with Kathy Brown at IBM Connect, Julian Robichaux has contributed a lightweight converter between JSON and Java, JsonBeanX. This is just a JAR file that can be imported into an individual NSF and avoids some of the security restrictions of other Java implementations, which would need amendments to the java.policy (or java.pol) file or would need the code adding to an OSGi plugin. Full details on how to implement it are in the JavaDoc documentation. This is designed to convert between JSON and Java objects, but it's an added incentive if needed to use Java instead of SSJS, to minimise the code you need to write and avoid some of the pitfalls you might otherwise need to (re-)address.

I've attached a simple example in the Java classes below. Within your XPages application, you would just go to JavaCode and import Julian's jar file, like this:
json_1.jpg

Then it's just a case of creating the Java code to use it. DavidJson is my Java class, which comprises a few properties - name, age, date of birth and characters. In the Utils class there is a method createBean() to create an instance of the class. (In reality, this would be loaded from a Notes Document , ViewEntry or multiple Documents/ViewEntries.)  The outputJson() method then uses just a handful of lines of code to return a String containing the JSON data:
json_2.jpg

When passed to a Computed Field component, the output is this:
json_3.jpg

Outside of XPages, the standard library for translating between Java and JSON is Jackson and Frank van der Linden is working on an OSGi plugin, already on OpenNTF's Stash, to wrap this for those who prefer something a bit meatier and can use OSGi plugins. The second output is the same DavidJson Java object outputted using Frank's plugin. Again, it's just a handful of lines of code.
json_4.jpg

The false parameter passed to the JacksonWrapper tells it to output date/times as date/times rather than converting them to timestamps. There are a variety of options for outputting to files, FileWriters, OutputStreams or just strings (which I use here). And beyond this there is a host of additional functionality from Jackson. Look out for a full release of this project on OpenNTF in the near future or download the source from Stash and get involved (developing, testing, adding feature requests or more).





---------------------
https://www.openntf.org/blogs/openntf.nsf/d6plinks/PWIS-A95GF9
Apr 18, 2016
6 hits



Recent Blog Posts
201
OpenNTF on Twitter
Fri, Nov 17th 2017 1:24p   Paul Withers
When the free non-production Domino server license was launched on developerWorks earlier this year, it brought that area of developerWorks to the conscious awareness for possibly the first time. I looked at the "Communities" sub-page and, in particular, the "Social" area near the bottom on the right. That highlighted that there were Twitter feeds being publicised that were not being maintained. That needed addressing. CollaborationToday has a team curating the content that appea
2
OpenCode4Connections Contest Winners
Thu, Oct 19th 2017 11:18a   Paul Withers
Earlier this week, at Social Connections, we announced the winners of the OpenCode4Connections IBM Connections Customizer contest. To support the contest there was a great amount of effort from Christian Guedemann, Martin Donnelly and others to set up the infrastructure and enablement materials to help ensure the contest was a success. Even though the contest only ran for a short period of time, the numbers were impressive: - over 40 organisations were provisioned by IBM during the p
4
OpenNTF Board of Directors
Thu, Sep 28th 2017 5:00p   Paul Withers
The new OpenNTF board has been elected by acclamation. The following have been elected Member Directors, returned for two years: Martin Donnelly - IBM Paul Withers - Intec Systems Ltd Oliver Busse - We4IT Nathan T Freeman - Red Pill Now They join the Member Directors elected last year, who have one year left on their term: Serdar Basegmez, Developi Information Systems Adam Foster, Oval Jesse Gallagher, I Know Some Guys Christian Güdemann, Webgate Dougla
7
Say hello to "OpenCode4Connections.org"
Thu, Sep 14th 2017 4:23p   Christian Guedemann
We at OpenNTF.org are excited to launch our new brand - OpenCode4Connections.org. OpenNTF has a proven track history in building open source communities around interesting technologies and products, e.g. it was the incubinator for the success of XPages. But let us welcome our newest member: OpenCode4Connections.org The intention behind OpenCode4Connections.org is a very simple and short story! IBM Connections deserves a dedicated place where the Open Source Community can meet and co
4
OpenNTF Board of Directors - Call for Nominations
Wed, Aug 23rd 2017 7:18p   Paul Withers
It's the time of year when we invite anyone interested in participating in OpenNTF's Board of Directors to submit their names to ip-manager at openntf.org. Employees of member organizations may be nominated as a Member Director – with a two-year term. There are four such board positions open for election. Contributors may be nominated as a Contributor Director – with a one year term. There are three such board positions open for election. The terms of fou
3
Social SDK - Bring it to the next stage
Mon, Apr 3rd 2017 4:04p   Christian Guedemann
The big intention of IBM's Social Business Tookit was to make the IBM Connections API easy to consume from any Web / Java platform. And it still is! But how to proceed with the Social SDK in the time of Connections Pink? It seems to be the right moment, for IBM and the OpenNTF community to join forces and bring the Social SDK to the next stage. The community has already moved on with the SocialSDK for bugfixes and also enhancements. But now it's time to make the SocialSDK ready for
1
OpenAPI Specifications for Freebusy and Calendar available on OpenNTF's Github account and SmartNSF Beta 2 released
Sat, Mar 11th 2017 2:22p   Christian Guedemann
The application development landscape of today's world is completely upside-down. While in the past a platform has to integrate all and should consume open standards, in today's world a platform should be capable of being integrated everywhere and providing open standards. This shift is a logical consequence of the new paradigms of microservices and microservice-oriented architecture. While the previous times an application development platform had to provide as many services as possibl
5
The winners of the IBM & OpenNTF Hackathon 2017 @IBM Connect
Fri, Feb 24th 2017 2:53p   Christian Guedemann
Thanks Alan Hamilton for producing and sharing this:
4
Hackathon 2017 - A Unique Opportunity
Sat, Feb 4th 2017 2:12p   Christian Guedemann
Dear friends, In only 2 weeks, we will do something that I was afraid to even dream of. After holding the ICS Developer Competition in 2016, we will hold the IBM and OpenNTF Hackathon @ IBM Connect 2017. Two weeks before the Hackathon, we have already achieved all of our targets: the type audience that we are and also the target numbers - 50 attendees two weeks before was our vision. We have nine really attractive projects with great project leaders (yes, they are really great!). We h
4
Project Spotlight: HR Assistant
Sun, Jan 22nd 2017 10:32p   Paul Withers
Last year OpenNTF jointly hosted an ICS development contest with IBM with a difference: there had to be a team involved. The winners were Frank van der Linden and Frederic Dehedin. The application covered a variety of technologies, including Bluemix, Cloudant, and Watson. It also used the Jackson JSON Mapper Frank also submitted to OpenNTF and which has been covered on this blog before. As well as being a competition winner, the project is of particular interest because it goes beyond the




Created and Maintained by Yancy Lent - About - Planet Lotus Blog - Advertising - Mobile Edition