2

For instance, a GET request to the standard endpoint node/1.json returns an object with fields like this:

{
   ...

   "field_my_field":{
      "und":[
         {
            "value":"yucky"
         }
      ]
   }

   ...
}

To build an easy to use API, we would want to GET and POST objects with fields like this:

{
   ...

   "my_field": "clean"

   ...
}

It would be easy to implement the vast majority of field types this way. I thought there was a module for this, but I can't find it.

1
  • I don't think there could be, fields are more complex than your desired output. e.g. there's a node field called body; if you were to add field_body as well, you'd immediately have a collision and one of the values would be lost. Similarly if it's multi-lingual, if the fields are multiple cardinality, have multiple columns, etc, they can't be generically represented in that way. I'd love to see a solution, though, I've been ruling Drupal out of API projects for exactly this reason lately
    – Clive
    Mar 12 '15 at 16:33
0

With the Services module, no. However you could build a Page display with Views datasource, that accepts a node id as a contextual filter. The fields you specify in the View can then be configured to "clean up" the property name (or just turn off the label to use the machine name of the field), and then the value will be "flat".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.