Question
· Dec 9, 2016

access object in a JSON array.

Hi,

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

http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=...

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

I would like to access the weather.id 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 = tProxy.weather.id
            set pResponse.WeatherMain = tProxy.weather.main
            set pResponse.WeatherDescription = tProxy.weather.description

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.

ERROR <Ens>ErrException: <PROPERTY DOES NOT EXIST>

Thanks in Advance.

Discussion (3)0
Log in or sign up to continue

<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?