Creating a reusable XML parser feature.
@todo
Example of a Flickr feed
A Flickr JSON parser for the Feeds extensible parsers module.
The feeds extensible parsers module is a set of extensible parsers for Feeds.
For now, use the documentation for Feeds XPath parser
Requires the QueryPath module.
See the QueryPath CSS Selector Reference.
To use the JSONPath parser, install the Feeds Extensible Parser module, then place the file 'jsonpath-0.8.1.php' into sites/all/libraries/jsonpath and clear the cache. When selecting a parser for a new Feed importer, the jsonPath Parser should now appear as an option
See the JSONPath expression tester.
Note: The JMESPath parser is preferred if you can meet the requirements.
See the JSONPath documenation.
To use the JMESPath parsers, you'll need Composer, and PHP >= 5.4.
In sites/all/libraries:
$ git clone https://github.com/mtdowling/jmespath.php.git
$ cd jmespath.php
$ composer install
$ drush cc all # Or just clear the cache however you normally would.
See the documentation for the selector syntax.
See http://jmespath.org for an expression tester.
See #2494185: JMESPath parser requirement for "Context" makes value inaccessible? for a practical example of how to configure the Context.
(source: https://www.drupal.org/project/feeds_jsonpath_parser)
Starting with the JSON document:
{ "store": {
"book": [
{ "category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{ "category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
},
{ "category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
},
{ "category": "fiction",
"author": "J. R. R. Tolkien",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
}
}
Assuming you have JSONPath expressions mapped to the Title, and Author fields, your expressions would look like:
Context: $.store.book.*
Title: title
Author: author@todo
A Flickr JSON parser for the Feeds extensible parsers module.