nesquena/rabl — Issue #139: How to be selective with root elements?
Author: neezer
Created: 2011-11-28 20:19:09+00:00
State: open

I've a deep-nested JSON structure that I'm having trouble duplicating with RABL... the problem is that some levels require root keys while others don't.

I want to do something like this:

[
{ first_root: {
blah: ...
another_blah: ...
nested_resources: [
{
some_other_blah: ...
}
]
}
]

So,

1. The top level have no root key (just an array of objects)
2. The second level (first_root) has a root key.
3. The third level (nested_resources) has a root key.
4. The fourth level (objects in nested_resources) have no root key (just an array of objects).

How would I do that? If I use `collection`, with include_json_root set to true, I get this:

[ { root_key: [ { root_2_keys: [ { root_2_key: {} } ] } ]

If I set that to false, I get this:

[ { [ {} ] } ]

I want something like this:

[ { root_key: [ {} ] } ]