Given that the only use of JSON output is as a display for feed or web services use, a Page display type isn't really appropriate. That's what the Feed display type is for. The style plugin can and should specify that it works only with Feed displays, which would likely simplify some code and be more in line with what users would expect.

Comments

earthday47’s picture

+1 agreed. I was confused for about 5-10 minutes, because I automatically went to "Feed" to add the JSON output. I actually thought there was a bug!

thommyboy’s picture

+1
otherwise one would always need to create a custom template to get rid of all the page-stuff or is there any easy workaround to just get the clean json output?

peterparker’s picture

I am also looking for a way to get clean json output. The preview when building the view is good, but using view.get returns far too much information.

Can anybody offer a solution?

Alexander Allen’s picture

Hi Peter,

If there is extra information that you need to be removed, fixing this issue won't solve your issue. Issue #1027590 (this issue) is related to how the Views displays are created/categorized (page, block, feed, etc.). Could you please create a separate issue for this and provide more details regarding the extraneous (non-clean) information that json is outputting?

tahiticlic’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev

Same needs here. I wonder what's the point to have a JSON output in a page... That's in a feed where it should output.

Alexander Allen’s picture

tahiticlic, let me be the devil's advocate for a second: the current VDS codebase is not flexible enough to allow users to customize the format or the output of the feeds in any way, when not using the drupal templating system. I do agree that this is not the way that this should be working, and that a feed is the way data should be served. If you feel that this is relevant to you, please feel free to subscribe to #1699368: #RVDA: Rewrite Views Datasource's Architecture, and to provide support with testing. This is currently being worked on.

eob’s picture

I am trying to configure a JSON view. Using this plugin to do the configuration was easy (thanks!), but when I load the URL, the JSON renders as text inside the HTML page instead of all by itself as a proper JSON document.

What am I doing wrong? How do I just get the JSON? That's the whole point of a JSON feed...

gnuget’s picture

Hi eob.

I found a way to display only the json and not the entire HTML page.

just edit your view and uncheck the "Views api mode" in the settings of "Json data document" now you will only see the json feed instead the entire site.

davidneedham’s picture

+1 agree it should use feed display rather than page.

@gnuget Thanks for the suggestion to uncheck the "views api mode" box. That fixed my original reason for visiting the queue!

IKE0088’s picture

When I uncheck views api mode, and attempt to visit the page, it attempts to include the output to a file to be saved on my desktop. Any ideas as to why it would do this? It is doing the same with Views GeoJSON module.

IKE0088’s picture

Appears to happen on IE8. Chrome works fine...

anthonylindsay’s picture

I read on StackOverflow that it's a known issue with IE8 that it doesn't play nice with application/json and you need to send it down the wire as text. There's a setting in the JSON format page style options on your view where you can choose whether to send it as application or text.

owntheweb’s picture

#8: gnuget: Thank you. :)

yannickoo’s picture

Hey guys, it's documented in the README.txt :)

Crell’s picture

yannickoo: That's nice. That's still the Wrong Way To Do It(tm) in Drupal 7. :-) Feed displays exist for this reason. Use 'em.

yannickoo’s picture

Oh, Crell replied me :o I guess that this issue cannot be solved in the 1.x branch of this module because it is a major update but if there is some time I will give my best to correct that part!

ZeiP’s picture

Category: Bug report » Feature request
Issue summary: View changes