Using JSONPath in your PHP application
Using JSONPath in your PHP application requires you to include the JSONPath PHP implementation available at https://code.google.com/p/jsonpath/, and parsing the JSON string to a PHP mixed object before applying the JSONPath path you want to extract data from with the jsonPath
function.
Getting ready
You'll need to download jsonpath.php
from code.google.com at https://code.google.com/p/jsonpath/ and include it in your application with the require_once
instruction. You'll also need to ensure that your PHP implementation includes json_decode
.
How to do it…
Here's a simple example:
<html> <body> <pre> <?php require_once('jsonpath.php'); $json = '…'; // from the introduction to this chapter $object = json_decode($json); ...
Get JavaScript JSON Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.