Registry / devops / php2json

php2json

JSON →
library0.2pypypiunverified

A Python library to convert PHP serialized data (from serialize()) or PHP session format to JSON. Supports nested arrays, objects, and various PHP types. Current version: 0.2. Low release cadence, last updated 2018.

pip install php2json
INSTALL
IMPORT
SIG · PHP2JSON
P
php2json
devopspythonv0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

convert
from php2json import convert
import php2json
The module exposes a single function `convert`; do not use php2json.convert (it works but is not typical).
convert_session
from php2json import convert_session
Separate function for PHP session format.

Converts a PHP serialized string to JSON (Python dict/list).

from php2json import convert php_serialized = 'a:2:{i:0;s:4:"test";i:1;s:5:"value";}' try: result = convert(php_serialized) print(result) # Output: ["test", "value"] except Exception as e: print(f"Error: {e}")
Debug
Known issues
gotchaThe library does NOT handle PHP serialized objects with class metadata (e.g., O:8:"stdClass":0:{}). It only converts data types (strings, integers, arrays, etc.).
fix
Pre-process the input to strip class info or use a more robust library like phpserialize.
affects: all
breakingVersion 0.2 changed the function signature from earlier versions (0.1). `convert()` now takes a string, not a file-like object.
fix
Ensure you pass a string directly.
affects: >=0.2
deprecatedNo official deprecations; low maintenance means bugs may not be fixed.
fix
Consider alternative libraries like phpserialize for active support.
affects: 0.2
gotchaThe library has limited error handling. Malformed PHP serialized strings may raise generic exceptions or return partial results.
fix
Wrap calls in try/except and validate input.
affects: all
Upgrade
Version history
0.2latest on PyPI · released Oct 17, 2017
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
php2json — pip install php2json · libregistry