-
Notifications
You must be signed in to change notification settings - Fork 336
Closed
Description
I'm trying to implement a simple JSON template, where JSON data is always returned under a 'result' node. (I have not yet attempted the layout techniques mentioned in Issues #87 & #99 - looking forward to the wiki article covering this). I may be misusing the 'node' concept of RABL.
Without the parent node
the JSON output is correctly named (after the child object), and includes the attributes I specify. Here is that RABL & output:
object false
node :error do
attributes @error
end
child @users do
attributes :name, :id, :state
end
{
-error: [
null
]
-users: [
-{
-user: {
name: "Billy_bob"
id: 853
state: "Texas"
}
}
...
With parent node
the JSON returns the data from the users, but includes all user fields under a 'data' node :
node :error do
attributes @error
end
node :result do
child @users do
attributes :name, :id, :state
end
end
{
-error: [
null
]
-result: [
-{
-data: [
-{
bearing: 225
country: "USA"
county: null
created_at: "2011-08-16T02:49:32Z"
description: null
distance: 17.20354345468381
id: 853
name: "Billy_bob"
state: "Texas"
updated_at: "2011-08-16T02:49:32Z"
}
-{
Metadata
Metadata
Assignees
Labels
No labels