Question
· 17 hr ago

%JSON.Adaptor compilation issues under array-of-streams and computed property types

For background, I've developed code that relies on %JSON.Adaptor functionality across an entire package of classes in our codebase. In regenerating these classes with %JSON.Adaptor as a superclass, I've encountered compilation errors from the JSON adaptor generators in certain classes, triggered by certain property types or parameters that are incompatible.

There are two causes for these compilation errors: either 1) the property is computed, and therefore certain property methods in the code generated by the JSON adaptor, such as ..SetObjectId(), do not exist, or 2) the property is an array of streams, which is explicitly unsupported by the generator and will throw an error early in the compilation process, effectively rendering that class incompatible with %JSON.Adaptor use.

For issue 1), the workaround I found is to setting the property parameter %JSONINCLUDE = "none", which will exclude that property from the %JSON.Adaptor generator. Fortunately for now, this workaround suffices, but it also seems like it would useful for the generator to directly avoid generating property methods that do not exist.

For issue 2), there is an explicit condition that checks for an array-of-streams property and quits with an error in %JSON.Generator:GenerateMapping, which is called early in the code generation process. 

I tried circumventing this check with different parameters and settings, including %JSONINCLUDE, but to no avail. My workaround has been to set the class parameter %JSONENABLED = 0 to disable the method generation entirely for that class and manually define the adaptor methods that would normally be generated. Of course, this is suboptimal in terms of consistency and maintainability.

First, I'm curious if anyone else has encountered this and has a better workaround to deal with it in the short term.

Second, it seems that the JSON Adaptor would be a little more robust if it excluded the array-of-streams properties without throwing an error, or at least allowed %JSONINCLUDE to control whether an array-of-streams property is included, like it does for other property types. This would allow the JSON adaptor logic to be generated for the rest of the class properties even if the class contains an array-of-streams property, something that I have not found possible currently. 

Of course, there may also be good reasons for the current behavior, so if anyone from the IRIS team can provide more insight on the existing design of %JSON.Adaptor, the feasibility of updating it, or any workarounds, I'd be interested in hearing your thoughts. 

Product version: IRIS 2023.1
Discussion (2)2
Log in or sign up to continue

I had a similar issues with IRIS 2021.2.

In one case a class with an object reference calculated property failed to compile.
The workaround was to add %JSONINCLUDE = "OUTPUTONLY" to the property.

The second case was a class that contains a property (not calculated) that is an array of %Stream.GlobalBinary (that was not supported) and despite I added %JSONINCLUDE = "NONE" the class did not compile.
For this I got a quick fix modifying a library class.

My suggestion is first to to reproduce the issue with a VERY SIMPLE test case and test it using latest IRIS version 2025.1 and, whatever the test result is, report it to WRC including the result of your test using the latest IRIS version.