trailblazer / roar

Parse and render REST API documents using representers.
http://www.trailblazer.to/gems/roar
MIT License
1.86k stars 138 forks source link

Can I sort/control the order of HAL JSON keys output? #81

Closed millisami closed 10 years ago

millisami commented 10 years ago

The HAL/JSON output is:

"{\"id\":1,\"name\":\"Centipede\",\"sub_type\":\"100 wheeler\",\"manufacturer\":\"Mahindra\",\"model\":\"Bolero\",\"year\":\"1990\",\"vin\":\"12345678\",\"license\":\"WA\",\"
_links\":{\"self\":{\"href\":\"http://127.0.0.1:3000/api/machines/1\"}}}"

But how can I place the _links key before id?

apotonick commented 10 years ago

Hi @millisami! You can do this.

module SongRepresenter
  include ...

  link :self ...

  property :id
millisami commented 10 years ago

@apotonick Thanks.

andresf commented 10 years ago

If I may ask, what's the use case for this behavior?

apotonick commented 10 years ago

I reckon it's beauty but I'm keen to know myself, @millisami !