access object in a JSON array.

Primary tabs

JSON, REST API, Ensemble


I am working with this Ensemble Business Operation, which extends the EnsLib.Rest.Operation.

I built the OpenWeatherMap Rest Operation described in the article above.

I would like to access the weather.main, and weather.description. However, these objects are in a JSON Array.

How do you access these three objects in Objectscript.

In my,  Test.REST.WeatherOperation class, I added these three lines.

            set pResponse.WeatherId =
            set pResponse.WeatherMain =
            set pResponse.WeatherDescription =

Also, in my Test.REST.WeatherResponse, response message class I added these three lines.

Property WeatherId As %String;
Property WeatherMain As %String;
Property WeatherDescription As %String;

I get this error, with the code I have.


Thanks in Advance.


<PROPERTY DOES NOT EXIST> means your code is trying to reference a class property that does not exist.  The rest of the error message should tell you which property you tried to reference that didn't exist.

After you added those 3 properties to the WeatherResponse class, did you save and compile it?

If you're not able to resolve this, can you post the complete error message?  What property is it telling you doesn't exist?

I read your question more carefully.  Here is example JSON with an array:





Here is how to access the contents of the array once it's loaded in the tProxy object:

USER>w tProxy.test
USER>w tProxy.arr.GetAt(1)
USER>w tProxy.arr.GetAt(2)


Hi, I added the following code and it works.

            set pResponse.WeatherId =
            set pResponse.WeatherMain =
            set pResponse.WeatherDescription =