JSON Import a List of Integers to Custom Message Class
I am working with a REST API JSON Response that contains a list of integers (departmentids).
JSON Response:
{
"status":"ACTIVE",
"departmentids":[
72
],
"subscriptions":[
{
"eventname":"LabResultAdd"
},
{
"eventname":"LabResultUpdate"
},
{
"eventname":"LabResultClose"
}
]
}
JSONJSON
I am having trouble getting that to parse into my custom message structure using the %JSONImport method.
Here is my custom message class (pResponse):
Class AH.AHLIB.Custom.Athena.Message.GetEventsSubscribedResponse Extends (Ens.Response, %JSON.Adaptor)
{
Property status As %String;
Property departmentids As list Of %Integer;
Property subscriptions As list Of AH.AHLIB.Custom.Athena.Message.GetEventsSubscribedResponse.subscriptions;
Storage Default
{
<Data name="GetEventsSubscribedResponseDefaultData">
<Subscript>"GetEventsSubscribedResponse"</Subscript>
<Value name="1">
<Value>status</Value>
</Value>
<Value name="2">
<Value>departmentids</Value>
</Value>
<Value name="3">
<Value>subscriptions</Value>
</Value>
</Data>
<DefaultData>GetEventsSubscribedResponseDefaultData</DefaultData>
<Type>%Storage.Persistent</Type>
}
}
ObjectScriptObjectScript
This is how the response parses in the message viewer trace:
How should I be defining the departmentids property in order to display in the XML Viewer?
I found this is just an issue with the UI - I may try extending the XML Adaptor on my message class to see if that will help display the field. But I am able to access my field and was able to test it was available with the following in studio console:
set msg=##class(AH.AHLIB.Custom.Athena.Message.GetEventsSubscribedResponse).%OpenId(<messageIDfromtester>)
set test=""
set tsC=msg.%JSONExportToString(.test)
w test