I am having a problem looping over an array created from Groupon JSON file.

New Here ,
Dec 10, 2015 Dec 10, 2015

Copy link to clipboard

Copied

I'm sure this is a simple thing to do, sadly I'm stuck! Any help would be appreciated.

I need to create a query from a json file from Groupon. I can get the file, deserialize it but then I just run into a brick wall!

<!--- Make the request to the API --->

<!--- Get the JSON Feed --->

<cfhttp url="https://partner-int-api.groupon.com/deals.json?country_code=IE&tsToken=IE_AFF_0_200012_212556_0&divi...">

<!--- Strip the function wrapper. --->

<cfset theData=REReplace(cfhttp.FileContent, 

        "^\s*[[:word:]]*\s*\(\s*","")>

<cfset theData=REReplace(theData, "\s*\)\s*$", "")>

<!--- Test JSON data. --->

<cfif !IsJSON(theData)>

    <h3>The URL you requested does not provide valid JSON</h3>

<cfelse>

<cfdump var="#theData#">

</cfif>

The file is at: http://www.thefuture.tv/grouponJSON.cfm

Views

153

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 10, 2015 Dec 10, 2015

Copy link to clipboard

Copied

I'm not sure what you're trying to do with the REreplace(), but you have an odd number of parenthesis (two left, one right) in that tag.  That might be part of the problem.

HTH,

^_^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 10, 2015 Dec 10, 2015

Copy link to clipboard

Copied

WolfShade I think the extra parantheses in both REReplace statements are escaped by the preceding backslash, so they may be intended.

leDuke‌ - I'm wondering why the need to do any REReplace stuff - when I look at the original URL in Chrome, it appears to be coming back as clean JSON.  What are you trying to solve?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 10, 2015 Dec 10, 2015

Copy link to clipboard

Copied

Not sure what you are doing with the REReplace.  If could explain the reason for this that may help.

If I run this I get a proper struct duped out.

<cfdump var="#deserializeJSON(cfhttp.FileContent)#">

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Dec 10, 2015 Dec 10, 2015

Copy link to clipboard

Copied

LATEST

leDuke wrote:

I need to create a query from a json file from Groupon. I can get the file, deserialize it but then I just run into a brick wall!

Until you tell us what the brick wall is, I shall assume it's the one between your kitchen and your living room.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines