Skip to content

Child object under node loses name, ignores attribute list #101

@rhb

Description

@rhb

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions