Question on JSON Feeds

Vroom

Member
I am trying to send an email importing a JSON feed. In the template I have added for example [JSON_FEED_ITEM_TITLE], but what should be the exact name for the variables in the JSON feed.

Is it JSON_FEED_ITEM_TITLE or is it TITLE, or is it something else?

I can't get it to pull anything so far with any of these names.
 

Vroom

Member
In case anyone else has the problem. The feed needs to start with [ and end with ], where as my feed was not. When I manually add that to my feed it works, but I still havent figured out how to make my feed output with that automatically.
 

twisted1919

Administrator
Staff member
In case anyone else has the problem. The feed needs to start with [ and end with ], where as my feed was not. When I manually add that to my feed it works, but I still havent figured out how to make my feed output with that automatically.
if you encode an array like
PHP:
$data = ['key1' => 'value1', 'key2' => 'value2']
Then you will not get, as you say, the [ and ] in your feed. In order to get them, you have to encode an array of arrays:
PHP:
$data = [
   ['key1' => 'value1', 'key2' => 'value2'],
   ['key1' => 'value1', 'key2' => 'value2']
];
exit(json_encode($data));
 
Top