I made my first plugin I don't deal allot with variable and parsing. it was a JSON data to pars to a template. the problem is when I decode the JSON to an array Then I use parse the variables to the template I can't get the variables in my plugin tag. I found a question similar to my question but it did work for me either .

Parsing JSON in EE tag

can i get help please :D

    public function __construct()
    $this->EE =& get_instance();
    $find   = array("<", ">");
    $rep = array("{", "}");
    $json = str_replace($find, $rep, $this->EE->TMPL->fetch_param('json'));
    $json = current(json_decode($json,true));
    $json['location'] = array(
    $json['social'] = array(

    $vars = (array) array($json);

    $this->return_data = $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $vars);
  • Can you post the relevant portion of your code, and an example of what the resulting array looks like? Apr 14 '15 at 12:58
  • sure and thanks :) I will update the question it self
    – Akwad Net
    Apr 14 '15 at 13:11

If it's not coming through, I'd bet it's malformed JSON, or more likely, your array structure is incorrect.


An easy way to test this is to dump your final array to the developer logger as json, and just compare the structure to how it should be as an array. To do this, add these lines of code right before you call parse_variables:


Then check the log in your control panel. It lives under Tools -> Logs -> Developer Log. Almost certainly you just have a malformed array structure. Compare your structure to the Ellis Lab examples.


in my case i get some json from other website it gives an ID for the returned json value. so I only needed the first element when decoding so I used $json = current(json_decode($json,true)) and then I add this element of array the $vars = (array) array($json); after that I pared the variable as well.

$this->return_data = $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $vars);


now it works find with me . thanks allot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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