Closed (fixed)
Project:
Open Data
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
15 Aug 2013 at 14:24 UTC
Updated:
9 Sep 2013 at 14:21 UTC
Jump to comment: Most recent file
Build a feature supplying a view for /data.json
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | project_open_data-view.patch | 38.9 KB | grasmash |
Comments
Comment #1
grasmash commentedTaking this!
Comment #2
grasmash commentedChanges pushed to repository. Patch attached. Please review!
Comment #3
barrett commented@madmatter23: it looks like this has already been merged. Can you confirm?
It looks like there are a couple problems with the json. With one dataset node, I'm seeing the output below. The opening doesn't line up with what's in the example json at http://project-open-data.github.io/examples/catalog-sample-extended.json
The distribution field also does not seem to be rendered correctly.
Comment #4
grasmash commentedInteresting. The preview in the Views UI shows output that matches the open data standards, but the actual output of the JSON at data.json differs. Seems like this could be a bug in views_datasource which, to be fair, is a dev version. I wonder if we can find an alternative or patch it.
Comment #5
grasmash commentedOk, got the general output looking better, but still need to work on the distribution field.
Considering a custom views handler or display formatter to handle the distribution field.
Comment #6
grasmash commentedAck, looks like views datasource doesn't play well with nested array or object in its output.
#1699368: #RVDA: Rewrite Views Datasource's Architecture
#1319714: Fields with multiple values are not displayed
This makes me consider outputting the JSON programmatically by building up and object structure in code outputting with drupal_json().
Comment #7
barrett commentedVery interesting.
Even on the preview though, the distribution field is borked.Ha! You added more comments while I was readingComment #8
barrett commentedThat's a shame, but I don't see a better solution unless we want to help Views Datasource with the rewrite they have been discussing for the past year and haven't completed.
Comment #9
grasmash commentedI created a new branch that generates the data.json output programatically. I don't think there is supposed to be any paging for data.json, so I don't think views actually offers that much. This also reduces dependencies.
Checkout git branch: manual-json-output.
Comment #10
grasmash commentedChanges have been merged into 7.x-1.x.
Comment #11
barrett commentedThe JSON looks good, Matt. Putting it through Project Open Data's validiator (http://project-open-data.github.com/json-validator/) complains about it lacking a data dictionary element, but I think that's a fault with the validator and not the JSON.
Comment #12
acouch commented@Barrett and others, please comment on this pull request: https://github.com/project-open-data/json-validator/pull/6 The JSON validator is not working correctly which is a hinderance to any adopters Drupal or otherwise. Great work!