You are here

README.txt in Views Json Source 8

Same filename and directory in other branches
  1. 1.x README.txt
CONTENTS OF THIS FILE
---------------------

 * Introduction
 * Requirements
 * Installation
 * Configuration
 * How it works
 * Maintainers


INTRODUCTION
------------

This module is an extension of views module to work with external JSON data.
Any JSON API can be configured, to render the data from the JSON through views.

 * For a full description of the module, visit the project page:
   https://www.drupal.org/project/views_json_source

 * To submit bug reports and feature suggestions, or to track changes:
   https://www.drupal.org/project/issues/search/views_json_source


REQUIREMENTS
------------

No special requirements.


INSTALLATION
------------

 * Install as you would normally install a contributed Drupal module.
   See: https://www.drupal.org/node/895232 for further information.


CONFIGURATION
-------------

No configuration is needed.


HOW IT WORKS
------------

When creating a view choose "JSON" on "Show" field.
On Edit View, In "Advanced" section, click "Settings" on "Query settings",
choose the source of the JSON data, define the row apath and you're done.
Now just add one or more fields and set the key value of the field to show.
Add any filters or sort criteria as required.
Make use of Contextual filters as required.

Example #1:
A file called nodes.json that is hosted on www.example.com with the
following structure:
{
  "data": {
    "nodes": [
      {
        "nid": 1,
        "title": "Sample Node One",
        "description": "Lorem ipsum dolor sit amet, consectetur adipiscing."
      },
      {
        "nid": 2,
        "title": "Sample Node Two",
        "description": "Lorem ipsum dolor sit amet, consectetur adipiscing."
      }
    ]
  }
}

Query settings:
  JSON File: http://www.example.com/example1.json
  Row Apath: nodes


Example #2:
A file called sample.json that is hosted on www.example.com with the
following structure:
{
  "data": {
    "nodes": {
      "contents": [
        {
          "id": 1,
          "title": "Sample One",
          "description": "Lorem ipsum dolor sit amet, consectetur adipiscing."
        },
        {
          "id": 2,
          "title": "Sample Two",
          "description": "Lorem ipsum dolor sit amet, consectetur adipiscing."
        }
      ]
    },
    "taxonomy": {
      "contents": [
        {
          "id": 1,
          "title": "Category One",
          "description": "Lorem ipsum dolor sit amet, consectetur adipiscing."
        },
        {
          "id": 2,
          "title": "Category Two",
          "description": "Lorem ipsum dolor sit amet, consectetur adipiscing."
        }
      ]
    }
  }
}

Query settings:
  JSON File: http://www.example.com/example2.json
  Row Apath: %/contents
Contextual Filter:
  Add a contextual filter of type "Apath Replacement".
Sample views url:
  http://<domain>/<views url>/nodes
  http://<domain>/<views url>/taxonomy


Example #3:
A file called nodes.json that is hosted on www.example.com with the
following structure:
[
  {
    "nid": 1,
    "title": "Sample One",
    "description": "Lorem ipsum dolor sit amet, consectetur adipiscing.",
    "related": [
      {
        "id": 11,
        "author": {
          "name": "One1"
        }
      },
      {
        "id": 12,
        "author": {
          "name": "One2"
        }
      }
    ]
  },
  {
    "nid": 2,
    "title": "Sample Two",
    "description": "Lorem ipsum dolor sit amet, consectetur adipiscing.",
    "related": [
      {
        "id": 21,
        "author": {
          "name": "Two1"
        }
      },
      {
        "id": 22,
        "author": {
          "name": "Two2"
        }
      }
    ]
  }
]

Query settings:
  JSON File: http://www.example.com/example3.json
  Row Apath: nid=2/related
Fields:
  JSON field: author/name


MAINTAINERS
-----------

Current maintainers:
 * Pradeep Venugopal (venugopp) - https://www.drupal.org/u/venugopp

File

README.txt
View source
  1. CONTENTS OF THIS FILE
  2. ---------------------
  3. * Introduction
  4. * Requirements
  5. * Installation
  6. * Configuration
  7. * How it works
  8. * Maintainers
  9. INTRODUCTION
  10. ------------
  11. This module is an extension of views module to work with external JSON data.
  12. Any JSON API can be configured, to render the data from the JSON through views.
  13. * For a full description of the module, visit the project page:
  14. https://www.drupal.org/project/views_json_source
  15. * To submit bug reports and feature suggestions, or to track changes:
  16. https://www.drupal.org/project/issues/search/views_json_source
  17. REQUIREMENTS
  18. ------------
  19. No special requirements.
  20. INSTALLATION
  21. ------------
  22. * Install as you would normally install a contributed Drupal module.
  23. See: https://www.drupal.org/node/895232 for further information.
  24. CONFIGURATION
  25. -------------
  26. No configuration is needed.
  27. HOW IT WORKS
  28. ------------
  29. When creating a view choose "JSON" on "Show" field.
  30. On Edit View, In "Advanced" section, click "Settings" on "Query settings",
  31. choose the source of the JSON data, define the row apath and you're done.
  32. Now just add one or more fields and set the key value of the field to show.
  33. Add any filters or sort criteria as required.
  34. Make use of Contextual filters as required.
  35. Example #1:
  36. A file called nodes.json that is hosted on www.example.com with the
  37. following structure:
  38. {
  39. "data": {
  40. "nodes": [
  41. {
  42. "nid": 1,
  43. "title": "Sample Node One",
  44. "description": "Lorem ipsum dolor sit amet, consectetur adipiscing."
  45. },
  46. {
  47. "nid": 2,
  48. "title": "Sample Node Two",
  49. "description": "Lorem ipsum dolor sit amet, consectetur adipiscing."
  50. }
  51. ]
  52. }
  53. }
  54. Query settings:
  55. JSON File: http://www.example.com/example1.json
  56. Row Apath: nodes
  57. Example #2:
  58. A file called sample.json that is hosted on www.example.com with the
  59. following structure:
  60. {
  61. "data": {
  62. "nodes": {
  63. "contents": [
  64. {
  65. "id": 1,
  66. "title": "Sample One",
  67. "description": "Lorem ipsum dolor sit amet, consectetur adipiscing."
  68. },
  69. {
  70. "id": 2,
  71. "title": "Sample Two",
  72. "description": "Lorem ipsum dolor sit amet, consectetur adipiscing."
  73. }
  74. ]
  75. },
  76. "taxonomy": {
  77. "contents": [
  78. {
  79. "id": 1,
  80. "title": "Category One",
  81. "description": "Lorem ipsum dolor sit amet, consectetur adipiscing."
  82. },
  83. {
  84. "id": 2,
  85. "title": "Category Two",
  86. "description": "Lorem ipsum dolor sit amet, consectetur adipiscing."
  87. }
  88. ]
  89. }
  90. }
  91. }
  92. Query settings:
  93. JSON File: http://www.example.com/example2.json
  94. Row Apath: %/contents
  95. Contextual Filter:
  96. Add a contextual filter of type "Apath Replacement".
  97. Sample views url:
  98. http:////nodes
  99. http:////taxonomy
  100. Example #3:
  101. A file called nodes.json that is hosted on www.example.com with the
  102. following structure:
  103. [
  104. {
  105. "nid": 1,
  106. "title": "Sample One",
  107. "description": "Lorem ipsum dolor sit amet, consectetur adipiscing.",
  108. "related": [
  109. {
  110. "id": 11,
  111. "author": {
  112. "name": "One1"
  113. }
  114. },
  115. {
  116. "id": 12,
  117. "author": {
  118. "name": "One2"
  119. }
  120. }
  121. ]
  122. },
  123. {
  124. "nid": 2,
  125. "title": "Sample Two",
  126. "description": "Lorem ipsum dolor sit amet, consectetur adipiscing.",
  127. "related": [
  128. {
  129. "id": 21,
  130. "author": {
  131. "name": "Two1"
  132. }
  133. },
  134. {
  135. "id": 22,
  136. "author": {
  137. "name": "Two2"
  138. }
  139. }
  140. ]
  141. }
  142. ]
  143. Query settings:
  144. JSON File: http://www.example.com/example3.json
  145. Row Apath: nid=2/related
  146. Fields:
  147. JSON field: author/name
  148. MAINTAINERS
  149. -----------
  150. Current maintainers:
  151. * Pradeep Venugopal (venugopp) - https://www.drupal.org/u/venugopp