Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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"
}
}
]
}
Comment | File | Size | Author |
---|---|---|---|
#14 | views_datasource-d7-1271506-14.patch | 1.68 KB | ZeiP |
#12 | interdiff-1271506-9-12.txt | 1.09 KB | jacob.embree |
#12 | views_datasource-d7-1271506-12.patch | 1.19 KB | jacob.embree |
#10 | views_datasource-d7-1271506-9.patch | 1.17 KB | michaelraasch |
Comments
Comment #1
meSteI 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..
Comment #2
SilviaT CreditAttribution: SilviaT commentedsame issue here
Comment #3
hbfkf CreditAttribution: hbfkf commenteddito here
Comment #4
meSteAny news?
Comment #5
choneysett CreditAttribution: choneysett commentedI 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.
Comment #6
michaelraasch CreditAttribution: michaelraasch commentedI 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
Comment #7
rooby CreditAttribution: rooby commentedI haven't tested but at first glance I wonder if
"field_{$id}";
is always going to be correct?Comment #8
farfanfelipe CreditAttribution: farfanfelipe commentedit looks good to me. I tested the functionally and it fixed the fields data values to return the right values.
Comment #9
farfanfelipe CreditAttribution: farfanfelipe commentedI 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
Field output: Row
Comment #10
michaelraasch CreditAttribution: michaelraasch commentedGood find. I have added a check for taxonomy. Please re-test with views_datasource-d7-1271506-9.patch
Comment #11
farfanfelipe CreditAttribution: farfanfelipe commentedIt looks to me now. Tested and it is perfectly working.
Comment #12
jacob.embree CreditAttribution: jacob.embree at St. Louis Integration commentedThis 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.
Comment #13
jacob.embree CreditAttribution: jacob.embree at St. Louis Integration commentedSee #2384329: views_json raw output does not provide correct field values for another approach.
Comment #14
ZeiP CreditAttribution: ZeiP as a volunteer commentedThis 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.
Comment #16
ZeiP CreditAttribution: ZeiP as a volunteer commentedComment #18
ZeiP CreditAttribution: ZeiP as a volunteer commentedCommitted 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!