Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
question on json
  • public function action_index()
     {
      $data['test']=\Format::forge(array('a'=> array('fname'=>'samit','lname'=>'rimal')))->to_json();
      return Response::forge(View::forge('welcome/index',$data,false));
     }
    
    i got the output :
    {"a":{"fname":"samit","lname":"rimal"}}
    what should i do to output:
    {"a":[{"fname":"samit","lname":"rimal"} ]}
  • Hum... No, the output is correct.
    public function action_index()
     {
      $data['test']=\Format::forge(array('a'=> array(array('fname'=>'samit','lname'=>'rimal'))))->to_json();
      return Response::forge(View::forge('welcome/index',$data,false));
     }
    

    is the correct way if you want the [] in json.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion