1

I'm trying to load a JSON feed and parse/display the data. My code below generates an error - "impossible to access id on a string variable". Below is some sample JSON data I get back along with code I tried to use to display. Any help accessing my JSON data would be hugely appreciated.

Code to load / display feed (does not work):

{% set params = {
    url: 'https://jsonURL',
    type: 'json',
    element: '',
    cache: 60,
} %}

{% set feed = craft.feedme.feed(params) %}

{% for node in feed %}
    node: {{ node.id }}
{% endfor %}

JSON feed data:

{
    "id":"546852386",
    "timestamp":"2019-10-17 15:35:47",
    "user_agent":"Mozilla",
    "remote_addr":"1234",
    "payment_status":"",
    "form":"12345",
    "latitude":"123",
    "longitude":"123",
    "data":[
        {
            "field":"83628997","value":"first = aa\nlast = a"
        },
        {
            "field":"83691483",
            "value":"1"
        }
    ],
    "pretty_field_id":"83628997"
}

1 Answer 1

1

I think I figured it out ... I guess since I'm only getting one results I can't actually loop through. Eg: the following works.

{% set feed = craft.feedme.feed(params) %}
id: {{ feed.id }}
form: {{ feed.form }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.