Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I would really like to be able to put the NodeID in de Top level Child element name:
Is this possible?
Thank you!
Kind regards
Comment | File | Size | Author |
---|---|---|---|
Schermafbeelding 2014-10-09 om 14.59.18.png | 14.35 KB | mindhunter75 |
Comments
Comment #1
kenorb CreditAttribution: kenorb commentedComment #2
anthonylindsay CreditAttribution: anthonylindsay at Annertech commentedI'm not sure that is how JSON should work.
The top level child element name should identify a class of thing, rather than a specific thing. So to illustrate, you could have a top level child element name of 'person' and then a property within that of 'John'.
You can certainly include the NID as a property within a child element. I don't see the advantage of having unique top level child names?
In any case, Views Datasource won't support that. I would reconsider how you want to parse the data in the client and work with the structure the module provides. E.g. iterate over your returned nodes and pull out node.nid to get the nids, or something like that. In fact, it should be as simple as using a dot operator to access the properties of a top level child element.