Download the PHP package serafim/json5 without Composer
On this page you can find all versions of the php package serafim/json5. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download serafim/json5
More information about serafim/json5
Files in serafim/json5
Informations about the package json5
JSON 5
The JSON5 Data Interchange Format (JSON5) is a superset of JSON that aims to alleviate some of the limitations of JSON by expanding its syntax to include some productions from ECMAScript 5.1.
This PHP library for JSON5 parsing and serialization based on pp2 grammar and contains full AST building process.
Summary of Features
The following ECMAScript 5.1 features, which are not supported in JSON, have been extended to JSON5.
Objects
- Object keys may be an ECMAScript 5.1 IdentifierName.
- Objects may have a single trailing comma.
Arrays
- Arrays may have a single trailing comma.
Strings
- Strings may be single quoted.
- Strings may span multiple lines by escaping new line characters.
- Strings may include character escapes.
Numbers
- Numbers may be hexadecimal.
- Numbers may have a leading or trailing decimal point.
- Numbers may be IEEE 754 positive infinity, negative infinity, and NaN.
- Numbers may begin with an explicit plus sign.
Comments
- Single and multi-line comments are allowed.
White Space
- Additional white space characters are allowed.
Short Example
Specification
For a detailed explanation of the JSON5 format, please read the official specification.
Installation
Install via Composer:
Usage
Benchmarks
- 100_000 iterations (PHP 8.1 + JIT on Ryzen 9 5900X).
Sample | Time | Operations (Per Second) |
---|---|---|
json_decode('42') |
0.0112s | 8 917 408 |
json_decode('{"example": 42}') |
0.0326s | 3 061 848 |
json5_decode('42') |
0.0545s | 1 832 646 |
json5_decode('{example: 42}') |
5.3956s | 18 533 |
Yep... Native json_decode
is faster =))
Issues
To report bugs or request features regarding the JSON5 data format, please submit an issue to the official specification repository.
To report bugs or request features regarding the PHP implementation of JSON5, please submit an issue to this repository.
License
See LICENSE
All versions of json5 with dependencies
ext-json Version *
phplrt/runtime Version ^3.1
symfony/polyfill-ctype Version ^1.25