Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rustjson/php-rapidjson
PHP Extension of rapidjson
https://github.com/rustjson/php-rapidjson
Last synced: about 2 months ago
JSON representation
PHP Extension of rapidjson
- Host: GitHub
- URL: https://github.com/rustjson/php-rapidjson
- Owner: rustjson
- Created: 2015-10-16T02:41:14.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-11-11T22:14:46.000Z (about 8 years ago)
- Last Synced: 2024-08-08T00:14:33.530Z (5 months ago)
- Language: C++
- Homepage:
- Size: 26.4 KB
- Stars: 9
- Watchers: 2
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-php-extensions - php-rapidjson - 此库有问题 (数据转换)
README
# php-rapidjson
[![Build Status](https://travis-ci.org/RustJason/php-rapidjson.png?branch=master)](https://travis-ci.org/RustJason/php-rapidjson)
PHP Extension of rapidjson (not finished yet)
# Requirement
PHP7
# Install
```sh
git clone --recursive https://github.com/RustJason/php-rapidjson
cd php-rapidjsonphpize
./configure --with-php-config=/usr/local/php/php-7.0.0/bin/php-config
make && make test
```
# Usage
```php
$json = '{"name": "Jason", "age": 23, "arr":["c", "e"], "obj":{"subobj"}}';
$obj = new Rapidjson($json);
//traversal
foreach($obj as $k => $v) {
echo "key = $k";
var_dump($v);
}//modify and reencode
$obj['name'] = 'Young';
var_dump($obj['name']);
echo $obj;//ongoing
//Array support and obj support```
#Result of benchmark(gcc -O3) [Script](https://github.com/RustJason/php-rapidjson/blob/master/benchmark.php):
```bash
json.len = 206082
string(6) "memeda"
newjson.len = 202313
Rapidjson.time: 2.2114210128784
Rapidjson.mem: 204912
string(6) "memeda"
newjson.len = 218756
json_decode.time: 15.593321800232
json_decode.mem: 1543856
```