How to get View display label for field? I'm trying to enable grouping for the Views Datasource module. I'm looping through the $rows array, which is where output is stored by the module before it's formatted into JSON. Problem is, the grouping field is stored in $options as its machine name, but $rows uses the user-defined label for field names. Basically, I just need a function to take the machine name for a field and return the display-set label for it. 

I already tried field_views_field_label, but it returns an array of the labels for fields defined in the content type, where I need the label defined in the view display.

$group = $options["grouping"][0]["field"];
// Get grouping field as defined by the field options in the view display
$root = $options["root_object"];
$top_child = $options["top_child_object"];
if ($group) {
  $grouped = array();
    foreach ($rows[$root] as $key =&gt; $array) { // Values are numeric
      // Grab the grouping field value from inside the 3rd-level array.
      // Creating a label for grouping field will break everything
      $groupnode = $array[$top_child][$group];
      foreach ($array[$top_child] as $prop =&gt; $value) {
        if ($prop != $group) { // Ignore grouped field
          $grouped[$root][$groupnode][$prop][$key] = $value;
        }
      }
    }
  $rows = $grouped;
}
I recommend to take a look at this answer which provides lots of information on how to change the output produced by Views Datasource. This should give you a starter.