I am trying to output the content i get from my Controller in my view as json, but i think i is outputting weird.
On the web i search json and it comes up with output looking like this:
{"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}}
However mine is just not formatted and looks like this.
[{"Customer":{"id":"1","first_name":"Ian","last_name":"Smith","address_1":"10 High Streets","address_2":"","town_city":"Plymouth","county":"Devon","postcode":"PL1 2JD"}},{"Customer":{"id":"2","first_name":"David","last_name":"Smith","address_1":"52 Low Avenue","address_2":"","town_city":"Exeter","county":"Devon","postcode":"EX2 1KO"}}]
How can i output it so it looks like the first one?
EDIT
Controller
$user = $this->Customer->find( 'all' );
$this->set( 'users', $user );
View
<?php echo json_encode($user); ?>