Skip to main content
Participant
Dec 10, 2015 10:11 AM UTC
Question

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

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 is closed to new replies. Start a new post to keep the conversation going.

    4 replies

    BKBK
    Community Expert
    Community Expert
    Dec 10, 2015 10:39 PM UTC

    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.

    Translate
    Dave Ferguson
    Participating Frequently
    Dec 10, 2015 5:45 PM UTC

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

    Translate
    WolfShade
    Legend
    Dec 10, 2015 2:04 PM UTC

    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,

    ^_^

    Translate
    Carl Von Stetten
    Legend
    Dec 10, 2015 5:26 PM UTC

    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?

    Translate