Convert PHP serializer strings to JSON
Project description
A small library that aims to provide a fast way of decoding PHP serialization format. Use it if you need to migrate large amount of PHP data and performance is essential.
The library provides only one function:
>>> import php2json >>> php2json.php2json(b's:3:"foo";') b'"foo"'
It’s goal is to convert PHP serializer string into JSON string as fast as possible. The assumption is that JSON decoders (such as standard json module or ujson) are much better optimized than phpserialize.
Here’s a simple benchmark where I pit phpserialize against php2json combined with ujson and json:
phpserialize: 6.60s php2json+ujson: 0.15s php2json+json: 0.19s speedup (ujson): 4337% speedup (json): 3485%
Installation
Install with:
pip install php2json
Tests
Run test with:
pip install tox make clean tox .
Benchmark
Run benchmark with:
pip install -r requirements-test.txt make bench
Limitations
Few limitations apply:
only deserialization is possible
PHP objects are not supported
behaviour is undefined in presence of unicode strings
input data must adhere to JSON standards, most notably: array keys must be strings or values easily convertible to strings (such as integers)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for php2json-0.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79c390a0701e5823c3cf2f8e528257a4348ac2895b59e51afc6a527b168a1a89 |
|
MD5 | e3eda202ed78f1771301010c0844b645 |
|
BLAKE2b-256 | ca23b5914d0999b282a393dbffb5c93fb5a806678ebd995350b50ef1f657397c |
Hashes for php2json-0.1-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b30559d5aa2491e97a1f12ecaa843acc4109d9e277ff7d38da62aac2f7aaf150 |
|
MD5 | a2d4e6e87eeb19150e52e6e4efa04850 |
|
BLAKE2b-256 | 2dfb44a52b8c65d2a317225833a6fc50237a64f65e48049ab4b45ea5dd1548f9 |