Can someone tell me if this JSON is in the correct format for EmberJS


#1

Hey ya’ll, It’s good to be back, it’s been about a year since I have used Ember and PHP together and all my working examples were lost (yes backup your backups). Anyway, I have my very simple application setup, no errors yet there is no data showing up on ember’s side. Could you please tell me if this is the correct JSON format Ember is looking for - I have tried JSONAPIAdapter and RESTAdapter both.

This is my php (I have 2 headers, one for CORS and one for JSON) for($i = 0; $i<count($output); $i++){

$response["contact"][$i] = [];
$response["contact"][$i]["fname"] = $output[$i]["fname"];
$response["contact"][$i]["lname"] = $output[$i]["lname"];

}
json_encode($response, JSON_PRETTY_PRINT);

Here is the JSON output


#2

It’s wrong for both. I guess the place where you find the docs changed over the past year :wink:

RESTAdapter expects pluralized object root: http://emberjs.com/api/data/classes/DS.RESTAdapter.html#toc_json-structure

JSONAPI is much more… compli… different: http://emberjs.com/api/data/classes/DS.JSONAPISerializer.html


#3

DOH, I forgot all about the API docs, stupid me was only going through the guides. Much appreciated Indr!