1

I am new in Drupal. I am using Drupal 7 and i have created a view based on the terms and displaying it as Block to display it in the website. But, I want to export the view data in the JSON format.

I have installed Views Datasource module and enabled it in the Module administration.

But, i can't see the way to export my current view data to JSON through this module.

Can any one please help? is there any settings i am missing?

or is there any easy way like modules or plugins i can use?

1

You can achieve this by combination of two modules. Views data export and Views data export - JSON support. Once you install these two modules create a view as data export and select format as JSON.

Step 1 Step 2

  • Hi, I have installed both modules but how to make it work? what i have to do to export my view to json? – mak Mar 21 '17 at 4:34
  • You're trying to export view data right? I have updated my answer above to include screenshot. I don't have JSON support installed but it should be same as setting up CSV option. – Ash U Mar 21 '17 at 22:38
  • Thanks for your answer. I can now display the data in JSON. Just one quick question. I am loading values from 2 terms and i want o create different arrays in the JSON file for example: { "cars": { "Nissan": [ {"model":"Sentra", "doors":4}, {"model":"Maxima", "doors":4} ], "Ford": [ {"model":"Taurus", "doors":4}, {"model":"Escort", "doors":4} ] } } – mak Mar 23 '17 at 1:59
  • Can you please elaborate what you're trying to achieve... – Ash U Mar 23 '17 at 2:01
  • But right now, i am getting this result [ {"no name":"<a href=\"\/color-management\/red\">Red<\/a>"} , {"no name":"<a href=\"\/color-management\/white\">white<\/a>"}] – mak Mar 23 '17 at 2:03
0

To use Views Datasource to output JSON:

  1. Enable the views datasource sub-module views_json
  2. Add a new Page display to your view
  3. Under "Format" switch to "JSON data document"
  4. Set the path for your display

views datasource json

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.