I’m working with a web API, which is returning the following data (this is a cfdump of the cfhttp.filecontent);
{"id":"xxx","service1":["xxx"],"service2":["xxx"]}
I need to be able to read this and determine if a service is on the list. For example,
<cfscript>
pdata = deserializeJSON(cfhttp.FileContent);
</cfscript>
<cfif IsDefined(pdata.service1)>Do something</cfif>
However, I’m receiving an error with the above code. I’ve only recently started working with JSON, and so far I’ve had reasonable success – but I’m stuck with this!
Any pointers much appreciated!
It should be
IsDefined("pdata.service1")I found it to be a little counter-intuitive at first, but JasonDean put it into perspective in the comments.