diff --git a/src/Plugin/formatter/FormatterJsonApi.php b/src/Plugin/formatter/FormatterJsonApi.php index e9f38eb0..5cbc6185 100644 --- a/src/Plugin/formatter/FormatterJsonApi.php +++ b/src/Plugin/formatter/FormatterJsonApi.php @@ -346,11 +346,11 @@ protected function renormalize(array $output, array &$included, $allowed_fields $new_includes_parents[] = $field_name; $included[$field_path][$include_key] = $this->renormalize($field_item, $included, $nested_allowed_fields, $new_includes_parents); $included[$field_path][$include_key] += $include_links ? array('links' => $include_links) : array(); - $rel[] = $element; + $rel[$include_key] = $element; } // Only place the relationship info. $result['relationships'][$field_name] = array( - 'data' => $single_item ? reset($rel) : $rel, + 'data' => $single_item ? reset($rel) : array_values($rel), ); if (!empty($relationship_links)) { $result['relationships'][$field_name]['links'] = $relationship_links;