jumichica/pjson

Methods to transform json files using maths, filters and more.

0.0.1 2023-07-19 13:55 UTC

This package is auto-updated.

Last update: 2025-03-19 17:27:16 UTC


README

Methods to transform json files, maths, filters and more

INSTALL

composer require jumichica/pjson

Examples

Arithmetic Procesing

If you define a atribute with an initial equal (=) the system analyze te content to eval the formula.

<?php
require_once __DIR__ . '/../vendor/autoload.php';

use Jumichica\Pjson\Math;

$omath = new Math();
$json = '[
{"A": 1,"B": 2, "C": "= A + B"},
{"A": 1, "B": 2, "C": "= A - B"},
{"A": 1, "B": 2,"C": "= A * B"},
{"A": 1,"B": 2,"C": "= A / B"}
]';
$pjson = $omath->arithmetic($json);
$pjson = json_decode($pjson);
print_r($pjson[0]->C->value);