CCK field names in JSON service results

Events happening in the community are now at Drupal community events on www.drupal.org.
datashaman's picture

When using the block display in views to generate a JSON object for the services module, specifically the views.get method, the names (and hence keys in JSON) generated are decidedly unfriendly.

For example:

{"#error":false,"#data":[{"nid":"56","node_data_field_identifier_field_footer_value":null,"node_data_field_identifier_field_footer_format":null,"node_type":"page","node_vid":"159","node_revisions_body":"","node_revisions_format":"2","node_revisions_teaser":"","node_title":"Career Advice","node_revisions_timestamp":"1266478559","node_data_field_identifier_field_whatsthis_value":"<p>Our career advice section provides you with excellent articles that can help you improve your career.<\/p>","node_data_field_identifier_field_whatsthis_format":"2"}]}

In the above case, I've attached a CCK field 'footer' to the content type, and the view is being accessed with an argument of field 'identifier'.

This wouldn't be so bad if it was consistent in its naming. Here's another example:

[{"#error":false,"#data":[{"nid":"113","node_data_field_footer_field_footer_value":null,"node_data_field_footer_field_footer_format":null,"node_type":"article","node_vid":"213","node_revisions_body":"<\/p><p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip:
...
...
...

In this case, the view is accessed by a taxonomy term. Note how the index for the footer_field is now 'node_data_field_footer_field_footer_value'.

Firstly, those field names are unwieldy and will require translation into something sane for the template users.

Secondly, there seems to be no apparent pattern to how those fields are named.

Is there anyone who can help me to understand this better, or find a way of renaming them to something more useful?

Content Construction Kit (CCK)

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: