Skip to main content
November 17, 2010
Question

JSON and isDefined

  • November 17, 2010
  • 3 replies
  • 533 views

Hi,

I am consuming some JSON data from www.worldweatheronline.com.  I send them long/lat details and get back weather info.  I get the results and DeserializeJSON them to to ouput the resultant array just fine, but what I don't know how to do is to handle the results when there are NONE.

My ouput is as follows:

#myJSON.data.weather.tempMaxC#

My question is, if there is no weather array returned how can I test for this?  Isdefined does not seem to be working for me.

Help Please.

Cheers,

Aaron.

    This topic has been closed for replies.

    3 replies

    BKBK
    Community Expert
    Community Expert
    November 21, 2010

    <cfset myTestString = "">
    <cfset myTestArray = arrayNew(1)>


    <cfoutput>
    isArray(myTestString): #isArray(myTestString)#<br>
    isArray(myTestArray): #isArray(myTestArray)#
    </cfoutput>

    commadelimited
    Known Participant
    November 20, 2010

    Would probably help to provide the JSON string you're receving from the remote call. Please provide the string with data, and one that has no data.

    Inspiring
    November 18, 2010

    Did you do:

    isDefined( variableName )

    instead of:

    isDefined( "variableName" )?