Question
· Jun 20, 2023

jsonProvider been deprecated

As it says in documentation %ZEN.Auxiliary.jsonProvider been deprecated. We been using it's functions like %ConvertJSONToObject, WriteJSONFromObject etc. Is there any replacement?

Product version: IRIS 2021.1
Discussion (4)3
Log in or sign up to continue

What do you do if your API calls a SOAP Internal and you get back a response  SOAP Client Classes generated from WSDL . 

You have to change those classes to extend %JSON.Adaptor,  Would have been nice not to change generated classes. 
For this reason it would be nice to be able to use %ZEN.Auxiliary.jsonProvider or then a replacement .

Or is there any other way of handling this?

Thomas,

That does present a problem.  At this time I don't believe we have a function for function replacement for that %ZEN.Auxilliary class.  There are issues with how that object to JSON mapping was done that could result in exceedingly large blocks of JSON.  I would encourage you to raise this issue with your Sales Engineer who would be in a good position to present a feature request in the proper context to Product Development.

In the meantime, I can suggest a couple of ways to deal with this.   

  1. Create a wrapper class for these message.  This wrapper would inherit from the SOAP message class and %JSON.Adaptor.  Now you should be able to use the methods to convert to JSON.  The downside of this is that you may need to create a number of these wrapper classes if the SOAP api is extensive.
  2. The "natural" form of SOAP is XML.  You could create or look for an XML to JSON conversion utility.  This could be done utilizing our Embedded Python capability.  There are techniques and Python libraries that could do this conversion.  One such technique can be found here:  https://www.geeksforgeeks.org/python-xml-to-json/.

To use Python Libraries in ObjectScript you import the Python libraries and then just call the methods.  Here is a small example of using the Python standard 'os' library.

set pyPaths = $System.Python.Import("os.path")
pyPaths.normpath(pyPaths.join(fullPath,"Source"))

If you wish to try option 2 here is a documentation link to help you get started.

Introduction to Embedded Python