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"
}
]
}
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | views_datasource-959244.patch | 1.51 KB | joshuajabbour |
| #1 | views_datasource-959244.patch | 1.25 KB | joshuajabbour |
Comments
Comment #1
joshuajabbour commentedThe 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).
Comment #2
joshuajabbour commentedThis updated patch also allows the "Root object name" to be left blank, giving you:
instead of:
Comment #3
joshuajabbour commentedComment #4
vantuykom commentedis 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
Comment #5
vasikesubscribe
also for "root_object"
Comment #6
rjbrown99 commentedNow 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.
Comment #7
rjbrown99 commentedMoving to RTBC, I'd love to see this rolled in as I dislike managing unofficial patches in my prod source tree :)
Comment #8
Dean Reilly commentedThis was fixed for 7.x-1.x in this issue https://www.drupal.org/node/981810
Comment #9
zeip commentedAs Drupal 6 has been EOL for years now, closing this issue as outdated.