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.

devops
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.

The module exposes a single function `convert`; do not use php2json.convert (it works but is not typical).

from php2json import convert

Separate function for PHP session format.

from php2json import convert_session

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 footguns
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.).
breakingVersion 0.2 changed the function signature from earlier versions (0.1). `convert()` now takes a string, not a file-like object.
deprecatedNo official deprecations; low maintenance means bugs may not be fixed.
gotchaThe library has limited error handling. Malformed PHP serialized strings may raise generic exceptions or return partial results.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
9 hits · last 30 days
gptbot
3
ahrefsbot
1
Resources