https://github.com/bitdotgames/php-jzon
https://github.com/bitdotgames/php-jzon
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/bitdotgames/php-jzon
- Owner: bitdotgames
- License: mit
- Created: 2020-06-29T13:18:08.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-02-01T10:50:50.000Z (over 4 years ago)
- Last Synced: 2023-03-05T02:42:31.410Z (about 3 years ago)
- Language: C
- Size: 23.4 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP JZON #
This is a small PHP library for parsing JZON documents.
This library has a pure PHP implementation and a *much* faster C version implemented as an extension. If the C extension is missing it gracefully fallbacks to the PHP implementation.
## What is JZON? ##
JZON is a *superset* of JSON which is designed to be actively edited by *humans*.
PHP JZON features:
* no need to worry about trailing commas
* one line comments starting with #
* simple array keys don't need to be quoted with ""
* parsing errors are shown in a friendly manner
### Quick Example ###
Say, you have the following JZON file example.json:
```
#!json
["foo",
"bar",
{meaning_of_life: 42,
#NOTE: no comma ahead
# and yes comments are supported!
hey: "bar"
"thatscool": 1
}
]
```
Now you can parse it this way:
```
#!php
string(3) "foo"
[1]=>
string(3) "bar"
[2]=>
array(3) {
["thatscool"]=>
int(1)
["meaning_of_life"]=>
int(42)
["hey"]=>
string(3) "bar"
}
}
```
## How do I get set up? ##
### PHP only version ###
* Clone the repo
* Include **jzon.inc.php** and use **jzon_parse($str)** function
### C extension(recommended) ###
* Clone the repo
* Follow the standard PHP extension installation procedure: **phpize && ./configure && make && make install**
* Add **"extension=jzon.so"** line to your php.ini
* Include **jzon.inc.php** and use **jzon_parse($str)** function
## Credits ##
C extension is based on a bit modified code from https://github.com/KarlZylinski/jzon-c repository.