Monday, March 23, 2015

Extending WLST with custom Java classes - the case of JSON parsing

I have recently looked into how to "modernize" the WLST Jithon/Python version - still sadly a prehistoric 2.2.1, while the recent-most Python version is 3.4.2 (Oracle.... how about doing something about WLST? ).

Here is some instructions on how to try this upgrade - but it's not supported, so do it at your own risk.

This is an increasingly painful limitation of WLST, that it can't use any "modern" Python package, like json.

The good news is that it's relatively easy to expand WLST with any Java library you wish: just add the JAR to the CLASSPATH in /opt/oracle/middleware11g/wlserver_10.3/common/bin/, import the Java class with "from com.bla.mypackage import MyClass" and you can use the custom code.

In case of json parsing, there is a popular Google GSON library you could incorporate:||gson|2.3.1|jar which comes with a rich User Guide

The API of this GSON is here ... it seems to be aimed at parsing a JSON string directly into a Java object... there doesn't seem to be room for a more casual, random approach.

The Oracle solution is more "casual" and reminiscent of a DOM approach to parsing... more suitable for a quickly hacked deserialization.

Anyway.... I wish I could simply use the Python JSON module...

No comments: