qligier/tjson-parser

This package is abandoned and no longer maintained. No replacement package was suggested.

A PHP parser for TJSON format

0.1.1 2017-10-25 19:44 UTC

This package is not auto-updated.

Last update: 2022-07-09 17:04:26 UTC


README

A TJSON parser written in PHP, using Phlexy as JSON lexer.

68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f716c69676965722f746a736f6e2d7061727365722e7376673f7374796c653d666c61742d737175617265 68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f716c69676965722f746a736f6e2d7061727365722e7376673f7374796c653d666c61742d737175617265 StyleCI Shield 68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d47504c25323076332d626c75652e7376673f7374796c653d666c61742d737175617265

Requirements

  • PHP 7.0 at minimum is needed;
  • The GMP extension.

Quick start

Installation

Install the library with composer:

composer require qligier/tjson-parser

Usage

$parser = new Kentin\TJSON\Parser;
$tjson = '{"message:u":"Hello World!"}';

var_dump($parser->parse($tjson));
/*
array(1) {
  'message' =>
  string(12) "Hello World!"
}
*/

Data mapping

  • Boolean values are returned as boolean;
  • Binary values are decoded and returned as string;
  • FloatingPoint values are returned as float;
  • Integer values are returned as GMP instance;
  • UnicodeString values are returned as string;
  • Timestamp values are returned as DateTime instance;
  • Array values are returned as indexed array;
  • Object values are returned as associative array;
  • Set values are returned as indexed array.

Compliance

This library tries to be fully compliant with the current draft-tjson-spec (April 15, 2017). Nonetheless, the following non-compliances are not excluded:

  • The library accepts various formatting for FloatingPoint and Integer values that could be forbidden by the spec.

Development

To check the library with Psalm (a static analysis tool for finding errors):

./vendor/bin/psalm

To execute the unit tests with PHPUnit (an unit testing framework):

./vendor/bin/phpunit

To check the library with Infection (a mutation testing framework):

./vendor/bin/infection --min-msi=100 --min-covered-msi=100

To check and fix the coding style with PHP Coding Standards Fixer (a tool to automatically fix PHP coding standards issues):

./vendor/bin/php-cs-fixer fix . --dry-run --diff
./vendor/bin/php-cs-fixer fix .