PHP code example of monster-anshu / jsonata-php

1. Go to this page and download the library: Download monster-anshu/jsonata-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

monster-anshu / jsonata-php example snippets




onster\JsonataPhp\Jsonata;

const expression = '
Account.Order.Product[Price > 50].{ "id": ProductID, "total": Price * Quantity }
';

const input = [
    "Account" => [
        "Order" => [
            "Product" => [
                ["ProductID" => "A1", "Price" => 100, "Quantity" => 2],
                ["ProductID" => "A2", "Price" => 30, "Quantity" => 1],
            ],
        ],
    ],
];


$jsonata = new Jsonata(expression);
$result = $jsonata->evaluate(input);
print_r($result);
bash
composer