Currently, the default JSON output looks like this:

{
  "nodes" : [
    {
      "node" : {
        "nid" : 1,
        "title" : "title",
        "field_1" : "value"
      }
    }
  ]
}

In my opinion, there's an extra, unnecessary wrapper object there (the one that wraps the "node"). AFAICT, that object will always only contain one property, the "node". However, when you update the settings for "Top-level child object" and set it to a blank value, your output looks like:

{
  "nodes" : [
    {
      "" : {
        "nid" : 1,
        "title" : "title",
        "field_1" : "value"
      }
    }
  ]
}

The following is ideal, more compact and doesn't lose any of the usability of the above.

{
  "nodes" : [
    {
      "nid" : 1,
      "title" : "title",
      "field_1" : "value"
    }
  ]
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joshuajabbour’s picture

The attached patch fixes this issue. It only applies to the "simple" json data format, as I'm not too up-to-speed on Exhibit (although at first glance, it appears the current Exhibit output is actually wrong).

joshuajabbour’s picture

This updated patch also allows the "Root object name" to be left blank, giving you:

[
  {
    "nid" : 1,
    "title" : "title",
    "field_1" : "value"
  }
]

instead of:

{
  "" : [
    {
      "nid" : 1,
      "title" : "title",
      "field_1" : "value"
    }
  ]
}
joshuajabbour’s picture

Status: Active » Needs review
vantuykom’s picture

is there a way that somebody can give me the patched module? I'm no developer and I really don't know how to patch. But I really need the top_child_object to be not required.

regards

vasike’s picture

subscribe
also for "root_object"

rjbrown99’s picture

Now using this in a prod environment. It was very helpful for exporting JSON that is consumable by the iPhone. +1 for RTBC from me, speaking of the patch in #2.

rjbrown99’s picture

Status: Needs review » Reviewed & tested by the community

Moving to RTBC, I'd love to see this rolled in as I dislike managing unofficial patches in my prod source tree :)

Dean Reilly’s picture

Issue summary: View changes

This was fixed for 7.x-1.x in this issue https://www.drupal.org/node/981810

ZeiP’s picture

Status: Reviewed & tested by the community » Closed (outdated)

As Drupal 6 has been EOL for years now, closing this issue as outdated.