2017 © Pedro Peláez
 

library ljson

JSON extended with pure functions. in PHP

image

ljson/ljson

JSON extended with pure functions. in PHP

  • Monday, July 2, 2018
  • by Kanti
  • Repository
  • 2 Watchers
  • 8 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 2 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

Packagist Packagist Travis Code Climate Code Climate, (*1)

LJSON

LJSON is a drop-in replacement for JSON which also allows you to parse and stringify pure functions and their contents. There are good security reasons for functions to be out of the JSON specs, but most of those are only significant when you allow arbitrary, side-effective programs. With pure functions, one is able to interchange code while still being as safe as with regular JSON., (*2)

note:
this is a port of LJSON for JavaScript originaly from MaiaVictor, (*3)

<?php
require_once "vendor/autoload.php";

// A random object with a pure function inside.
$person = [
    "name" => "John",
    "mail" => function ($msg) {
        return [
            "author" => "John",
            "message" => $msg,
        ];
    },
];

$personStr    = \LJSON\LJSON::stringify($person);
$personVal    = \LJSON\LJSON::parse($personStr);
$mailFunction = $personVal->mail;
$mail         = $mailFunction("hello");// would crash with json_encode

echo $personStr . "\n";
echo \LJSON\LJSON::stringify($mail) . "\n";

output:

{"name":"John","mail":(v0) => ({"author":"John","message":v0})}
{"author":"John","message":"hello"}

More info:

Installing

composer require ljson/ljson

The Versions

02/07 2018

dev-master

9999999-dev

JSON extended with pure functions. in PHP

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

06/06 2017

dev-Kanti-patch-1

dev-Kanti-patch-1

JSON extended with pure functions. in PHP

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

29/07 2016

v0.3.1

0.3.1.0

JSON extended with pure functions. in PHP

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

21/12 2015

v0.3.0

0.3.0.0

JSON extended with pure functions. in PHP

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

16/12 2015

v0.2.6

0.2.6.0

JSON extended with pure functions. in PHP

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

13/11 2015

v0.2.5

0.2.5.0

JSON extended with pure functions. in PHP

  Sources   Download

GPL-2.0

The Requires

  • php >=5.4.0

 

The Development Requires

02/11 2015

v0.2.1

0.2.1.0

JSON extended with pure functions. in PHP

  Sources   Download

GPL-2.0

The Requires

  • php >=5.4.0

 

The Development Requires

23/10 2015

0.2.0

0.2.0.0

JSON extended with pure functions. in PHP

  Sources   Download

GPL-2.0

The Requires

  • php >=5.4.0

 

The Development Requires

23/10 2015

0.1.0

0.1.0.0

JSON extended with pure functions. in PHP

  Sources   Download

GPL-2.0

The Requires

  • php >=5.4.0

 

The Development Requires