vendredi 26 décembre 2014

Rails: change default JSON structure

I'm new in Rails and I use the version 4.2.0.


Let's suppose that we have the following JSON at the url localhost:3000/users



[{id: 1, "firstName": "John","lastName": "Smith"},
{id: 2, "firstName": "John","lastName": "Red"}]


but this is not what I want, I expect something like:



{ users :[
{id: 1, "firstName": "John","lastName": "Smith"},
{id: 2, "firstName": "John","lastName": "Red"}
]}


How can i do? Thanks everybody.





Aucun commentaire:

Enregistrer un commentaire