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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kenorb’s picture

Assigned: mindhunter75 » Unassigned
anthonylindsay’s picture

Status: Active » Closed (works as designed)

I'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.