Published on InterSystems Developer Community (https://community.intersystems.com)

Home > Advice about JSON conversions and reading outputs from Dynamic Objects

Question
Pavithra Rajamohan · Oct 2, 2020

Advice about JSON conversions and reading outputs from Dynamic Objects

Hi all,

I need some advice about JSON conversions and the outputs. I am being sent a JSON response from an API call and I am struggling to produce an output that I can use from it.

I have used the %FromJSON() method call to take the JSON stream source (pData) and convert it to a Dynamic object (object) but I am a little unsure as to how I can read the dynamic object and use it to extract the values from this and set the values as a property in another class.

The current coding I have for the conversion:

set object = ##class(%DynamicAbstractObject).%FromJSON(pData)

$$$TRACE("object:"_object)

set jnew = object.%Get("forename")

$$$TRACE("jnew:"_jnew)

I have tried %Get() as a way to try and get the values from within the object but this does not return a value.The traces also do not a return a readable value. Any suggestions on how I can read the values within the object and also extract them?

Thanks!

#JSON #Caché

Source URL:https://community.intersystems.com/post/advice-about-json-conversions-and-reading-outputs-dynamic-objects