Skip to content

Instantly share code, notes, and snippets.

@dkamioka
Created December 5, 2013 16:33
Show Gist options
  • Save dkamioka/7808612 to your computer and use it in GitHub Desktop.
Save dkamioka/7808612 to your computer and use it in GitHub Desktop.
json.root do
json.array! @root_array do |json, item|
json.id item[:id]
json.array!(item.nested_array) do |json, nested_item|
json.nid nested_item.nid
end
end
end
@AccurateSensors
Copy link

Goog.....:)

@dkamioka
Copy link
Author

dkamioka commented Dec 5, 2013

We tried Google, StackOverflow and beware! Even the documentation! Do you know how to help?

@ericksprengel
Copy link

{
  "root": [
  {
    "id": 1
    "nested_array": [
      {
        "nid": 11
      },
      {
        "nid": 12
      }
    ]
  },
  {
    "id": 2
    "nested_array": [
      {
        "nid": 21
      },
      {
        "nid": 22
      }
    ]
  }
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment