Hi!

I tried to create a JSON view from nodes but result is filled with different field names and just node id as value for each field (except for title and nid).

This problem came up while using raw output which seems to be the key to this problem since changing back to normal output field names and values match again.
Maybe some array gets false indexes while generating raw output?

Also watchdog has some errors:
Couldn't find constant JSON_FORCE_OBJECT @ template_preprocess_views_views_json_style_simple() row 31

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

reb00ter’s picture

trying to make custom template for views row, but for every field of node $field->raw gives me $fields['nid']->raw. $field->content outs correct value, but I need to get not formatted integer value without suffix and prefix
am I doing something wrong?

rfay’s picture

Priority: Normal » Major

This is a major problem, would love to hear if anybody has looked at it. Changing to major, as it makes all raw json with fields unusable.

rfay’s picture

Status: Active » Needs review
FileSize
1.37 KB

I'm no views expert, but the code was not reaching into places that work for the raw values.

This patch makes it at least *find* the right values. Reviews and improvement appreciated.

rfay’s picture

Title: Only node id and title available on raw output » views_json raw output does not provide correct field values
killes@www.drop.org’s picture

Status: Needs review » Reviewed & tested by the community

Works great!

jacob.embree’s picture

#3 worked for me as well.

jacob.embree’s picture

Is there a good way to determine which column to return when there is no group_column, such as with image fields? The group_column is set in the field handler's option definition. It looks for a single column or a 'value' column. Fields such as image have more than one column and no 'value' column so the raw value will always be blank.

ZeiP’s picture

Status: Reviewed & tested by the community » Closed (duplicate)
jacob.embree’s picture

Status: Closed (duplicate) » Needs work
Issue tags: -raw, -nid, -fields +Needs reroll

This patch solves a problem that is not solved by #1271506: use field_output: raw get wrong outputs. In that one the column used to determine the raw value is hard coded. In this one the column is based on the column selected in the view. For example, with this patch one is able to get the raw tid from a taxonomy_term_reference field. With #1271506: use field_output: raw get wrong outputs that is impossible because "name" is always selected.

When this patch is rerolled it would be good to include the changes from https://cgit.drupalcode.org/sandbox-jacob.embree-2838147/commit/?id=4e134d2 and https://cgit.drupalcode.org/sandbox-jacob.embree-2838147/commit/?id=6b1ec98 made in my fork.

jacob.embree’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
2.51 KB

Does this work just as well for fields like url, email, and video?