198 Lotus blogs updated hourly. Who will post next? Home | Blogs | Search | About 
 
Latest 7 Posts
Say hello to "OpenCode4Connections.org"
Thu, Sep 14th 2017 35
OpenNTF Board of Directors - Call for Nominations
Wed, Aug 23rd 2017 5
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 4
The winners of the IBM & OpenNTF Hackathon 2017 @IBM Connect
Fri, Feb 24th 2017 4
Hackathon 2017 - A Unique Opportunity
Sat, Feb 4th 2017 5
Project Spotlight: HR Assistant
Sun, Jan 22nd 2017 8
Top 10
Say hello to "OpenCode4Connections.org"
Thu, Sep 14th 2017 35
On OpenNTF: Agendas for Meeting Rooms displayed in front of the Rooms
Tue, Apr 8th 2014 8
On OpenNTF: Script Portlet Samples for IBM WebSphere Portal
Wed, Apr 9th 2014 8
Project Spotlight: JsonBeanX and Jackson4XPages
Mon, Apr 18th 2016 8
Project Spotlight: OpenLog, XPages OpenLog Logger, XLogBack
Wed, May 25th 2016 8
Project Spotlight: HR Assistant
Sun, Jan 22nd 2017 8
Overview of the XPages Scaffolding Project on OpenNTF
Thu, Mar 20th 2014 7
On OpenNTF: PC Config - easy inventarisation of hard- & software
Wed, Jul 2nd 2014 7
The OpenNTF Vote is next week!
Tue, Sep 16th 2014 6
Announcing Extension Library Release 16 for Notes/Domino 9.0.1
Thu, Feb 18th 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
9 hits



Recent Blog Posts
35
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
5
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
4
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
4
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:
5
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
8
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
6
Learn, share and collaborate - The monday at IBM Connect is YOUR Day
Mon, Jan 16th 2017 9:48a   Christian Guedemann
LotusSphere/IBM Connect/IBM ConnectED have always been great events. And it's absolute natural to expect the same for this years edition. A first dive into the session list let you proof the expectation. But for me as a developer, there was always something missing at this events. The hands on experience. Yes there where labs (which I enjoy), but try to do something cool and crazy. Work together with other developer and do something special.... There was no time, to many good sessions,
4
While we are celebrating 15 Years of OpenNTF - Another era has come to a well deserved end!
Fri, Dec 16th 2016 7:19p   Christian Guedemann
15 Years old! Founded as Notes Open Source Software and renamed to OpenNTF, OpenNTF.org has become 15 years old. I think the founders of OpenNTF, Bruce Elgort and Nathan T. Freeman, and also Vince Shuurman who was involved in the early Years of OpenNTF did not imagine how important OpenNTF would become after all these years. OpenNTF, the home of the Extension Library, the home of over 850 Project and the place where IBM ICS learned how to reintegrate open source code in to a core product.
4
Contributor Elections
Mon, Sep 26th 2016 7:39a   Oliver Busse
The OpenNTF Contributor election results are in - and the winners are: Padraic Edwards, Fredrik Norling and Johnny Oldenburger. Congratulations to all the candidates. It was a good race, and we appreciate the involvement of all those who participated, whether by running or voting.




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