Skip to main content
Participant
December 10, 2015
Question

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

  • December 10, 2015
  • 3 replies
  • 374 views

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&division_id=dublin&offset=0&limit=20">

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

    This topic has been closed for replies.

    3 replies

    BKBK
    Community Expert
    Community Expert
    December 10, 2015

    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.

    Dave Ferguson
    Participating Frequently
    December 10, 2015

    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)#">

    WolfShade
    Legend
    December 10, 2015

    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,

    ^_^

    Carl Von Stetten
    Legend
    December 10, 2015

    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?