loentar/ngrest

Is there a way to return result as json without the "result" element?

Closed this issue · 1 comments

Hi,
first of all great project!!
second, I was wondering if there is a way to return the result as pure json?
return result is now:
{"result":{"Pets":[{"species":"canine","name":"spot","birthday":"Jan 1, 2010"},{"species":"feline","name":"puff","birthday":"July 4, 2014"}]}}
I would like to get:
{"pets":[{"species":"canine","name":"spot","birthday":"Jan 1, 2010"},{"species":"feline","name":"puff","birthday":"July 4, 2014"}]}

found this:
Please upgrade ngrest and try new attributes:
inlineResult - to make particular operation respond without being wrapped into "result"
interface.defaultInlineResult - make the same as above but for any services and operations declared within this interface file
You can apply either or both, inlineResult takes precedence over interface.defaultInlineResult. By default both attributes has false value.

-- yourservice.h

// *interface.defaultInlineResult: true

class YourService: public ngrest::Service {
...
// *inlineResult: true
std::list getPets(); // result will be inlined due to inlineResult: true

// *inlineResult: false
std::list<Pet> getPetsNoInline(); // result will be NOT inlined due to inlineResult: false


std::list<Pet> getPets2();  // result will be inlined due to interface.defaultInlineResult