Written by

Senior Software Engineer
Question Ashok Kumar T · Dec 17, 2023

Error While Extending %JSON.Adaptor in xData MimeType of application/json

Hello Community,

I've extended the a class %JSON.Adaptor in my class definition and it contains the xData block MimeType of application/json. I got the error while compiling. Why this error occurs and how to resolve it

Product version: IRIS 2023.2
$ZV: RIS for Windows (x86-64) 2023.2

Comments

Enrico Parisi · Dec 18, 2023

It seems you cannot use ax XData block of "MimeType = application/json" within a class that extends %JSON.Adaptor.

Put your XData block in a different class that does not extends %JSON.Adaptor.

This may be a bug, (it looks so to me), you may want to report it to WRC.

Enrico

0
Herman Slagman · Dec 18, 2023

I've reported this to WRC more then a year ago, They didn't seemed bothered.

0
Enrico Parisi · Dec 18, 2023

Yeah, it has happened to me too, it seems WRC is not interested in fixing/reporting bugs when any sort of workaround is possible/available, like using a different class in this case.

The community is frequented by InterSystems product managers, developers, sales engineers and many other InterSystems people, maybe out of compassion will report it and will get it fixed, so maybe in IRIS 2026 we will see it fixed! 😂

Fixing this does not seems to be difficult, it's just  matter of filtering/checking the XData block  before (blindly) using it as JSON map.

I'm not holding my breath....

0
Timothy Leavitt · Dec 18, 2023

FWIW, I've nudged internally on the bug report for this and mentioned the post.

0
Vitaliy Serdtsev · Dec 19, 2023

It is strange that the bug has not been fixed yet, because it is easy to fix it by adding one line to <FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%JSON.Generator</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">GenerateMappingFromXdata</FONT><FONT COLOR="#000000">()</FONT>:

<..>
For i=1:1:count {
  Set xdata=compiledclass.XDatas.GetAt(i)
  Set configName=xdata.Name
  If configName="" Continue ; since the Name field is required, how can it be empty?
  If xdata.MimeType'="text/xml" Continue
<..>

PS: by the way, I didn't quite understand why need to check "configName", given that "Name" is a required field. Any ideas?

0
David Hockenbroch  Dec 19, 2023 to Vitaliy Serdtsev

Maybe that's old code that's been carried over through some copying and pasting. I have a Cache 2012 instance and Name is not required in it.

0
Vitaliy Serdtsev  Dec 20, 2023 to David Hockenbroch

Yes, most likely this is legacy code. For some reason I thought that since the %JSON package classes appeared only in IRIS, the code would also have to be new.

PS: by the way, can you compile an XData block without a name? Studio doesn't highlight the error?

0