Search code examples
jsoncoldfusioncfhttpcfloop

Coldfusion parsing cfhttp.filecontent into list


I am trying to parse through a cfhttp.filecontent that is returned and evaluate each variable.

Here is an example of what is being returned:

{"multicast_id":6110507831830919692,
 "success":0,
 "failure":1,
 "canonical_ids":0,
 "results":[{"error":"NotRegistered"}]}

So I would like to set to a list and loop through it so I can get the following:

multicast_id VARCHAR
success BIT
failure BIT
canonical_ids BIT
results VARCHAR

Any ideas would be great!!!

Thanks!


Solution

  • You need to have a proper CF object. cfhttp.filecontent is a just a string.

    <cfscript>
    data = DeserializeJSON(cfhttp.filecontent);
    
    
     writedump(data); // now you should have a proper cf variable.
    </cfscript>
    

    enter image description here