I am using view_json (7.x-1.x-dev) at drupal 7.8(Views 7.x-3.0-rc1), I can get correct result while selecting field_output:normal

{
  "nodes" : [
    {
      "node" : {
        "title" : "issue1",
        "Index" : "1",
        "Type" : "Image",
        "Body" : "We are going online\n",
        "Detail Theme" : "default",
        "Summary Theme" : "summary",
        "Title Theme" : "title",
        "Updated date" : "09/06/2011 - 16:49"
        "Nid":"7"
      }
    }
  ]
}

but when I select field_output:raw the result goes wrong, only field (like: title, nid)in the node table are correct, others fields which defined by admin (like: field_issueindex) get wrong value

{
  "nodes" : [
    {
      "node" : {
        "title" : "issue1",
        "field_issueindex" : "7",
        "field_issuetype" : "7",
        "body" : "7",
        "field_detailtheme" : "7",
        "field_summarytheme" : "7",
        "field_titletheme" : "7",
        "changed" : "1315298969"
        "Nid":"7"
      }
    }
  ]
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

meSte’s picture

I have the same problem. Setting "raw" as field output in style options brings to wrong data: instead of the selected fields it shows always the nid.
I'm using D7.7 + views 7.x-3.0-rc1 + view_xml (views_datasource 7.x-1.x-dev).
Don't know if this can help, but the only correct data in my views are: title, location:latitude and location:longitude. Maybe also body and other location fields are properly handled but i can't tell since i'm not defining values for those fields..

SilviaT’s picture

same issue here

hbfkf’s picture

dito here

meSte’s picture

Any news?

choneysett’s picture

I am also getting incorrect data when using raw output for view_xml. All fields for me are correct EXCEPT for the image field which, like the example in the first post, is only outputting the node ID. If I set field output to Normal, than an apostrophe that is in one of my fields gets encoded to ' which I DON'T want it to do. Switch to raw output fixes that issue, but then causes the issue in the image field. I'm discouraged to see how long ago this was originally posted with no resolution in sight.

michaelraasch’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
993 bytes

I came across the same problem today. I have looked at the code and have come up with a patch that works for me. Please find attached

rooby’s picture

I haven't tested but at first glance I wonder if "field_{$id}"; is always going to be correct?

farfanfelipe’s picture

it looks good to me. I tested the functionally and it fixed the fields data values to return the right values.

farfanfelipe’s picture

I tested with the article content type, using different types of fields. It works well but when it does not work properly when I have a field using a taxonomy (Sex field).

Field output: Normal

{
      "node" : {
        "title" : "This is a succesfull test",
        "Test field" : "5 678 733",
        "Qualified" : "Yes",
        "Body" : "This is the body of the succesfull test\n",
        "Sex" : "Masculin"
      }
    },

Field output: Row

{
      "node" : {
        "title" : "This is a succesfull test",
        "field_test_field" : "5678733",
        "field_qualified" : "1",
        "body" : "This is the body of the succesfull test",
        "field_sex" : ""
      }
    },
michaelraasch’s picture

FileSize
1.17 KB

Good find. I have added a check for taxonomy. Please re-test with views_datasource-d7-1271506-9.patch

farfanfelipe’s picture

Status: Needs review » Reviewed & tested by the community

It looks to me now. Tested and it is perfectly working.

jacob.embree’s picture

This patch changes #10 only to comply with Drupal coding standards on Control Structures and comment line wrapping.

I can confirm that #10 and #12 work as intended.

jacob.embree’s picture

ZeiP’s picture

This looks good, thanks! There were some field types that the patch didn't support, so here's a new patch with a wider support for different fields.

ZeiP credited rfay.

ZeiP’s picture

  • ZeiP committed ee62571 on 7.x-1.x
    Issue #1271506 by michaelraasch, jacob.embree, ZeiP, rfay: use...
ZeiP’s picture

Status: Reviewed & tested by the community » Fixed

Committed the patch with some of the logic fixed according to the patch in #2384329: views_json raw output does not provide correct field values. Thanks everyone!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.