Registry / serialization / jsonasobj2

jsonasobj2

JSON →
library1.0.4pypypi✓ verified 85d ago

Python library for converting JSON to Python objects and back, version 2. Current version 1.0.4, updated June 2023. Active development with infrequent releases.

pip install jsonasobj2
INSTALL
IMPORT
SIG · JSONASOBJ2
J
jsonasobj2
serializationpythonv1.0.4
Install
1.5s avg
Import
126ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.126s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.126s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

JsonObj
from jsonasobj2 import JsonObj
from jsonasobj import JsonObj
jsonasobj (v1) is a separate library; jsonasobj2 changed the import path.

Create and manipulate JSON objects using attribute access. JsonObj wraps dict and allows dot notation.

from jsonasobj2 import JsonObj # Create a JsonObj from a dict data = {'name': 'Alice', 'age': 30} obj = JsonObj(**data) print(obj.name) # Alice print(obj.as_json()) # '{"name": "Alice", "age": 30}' # Convert JSON string to JsonObj json_str = '{"key": "value"}' obj2 = JsonObj.from_json(json_str) print(obj2.key) # value
Debug
Known issues
deprecatedThe old jsonasobj library is deprecated. Use jsonasobj2 for new projects.
fix
Replace 'import jsonasobj' with 'from jsonasobj2 import JsonObj'.
affects: all
gotchaJsonObj does not support attribute names that are Python reserved words (e.g., 'class'). Use dict access instead.
fix
Use obj['class'] or setattr(obj, 'class', value) if needed.
affects: all
gotchaJsonObj.from_json() is a class method that returns a new JsonObj. It does not modify the existing instance.
fix
Assign the result: obj = JsonObj.from_json(json_string).
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'jsonasobj'
Installed jsonasobj2 but tried to import 'jsonasobj' (v1).
fix
Use: from jsonasobj2 import JsonObj
AttributeError: 'JsonObj' object has no attribute 'from_json'
Calling from_json() on an instance instead of the class.
fix
Use JsonObj.from_json(json_string) as a class method.
Upgrade
Version history
1.0.4latest on PyPI · released Jun 2, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
jsonasobj2 — pip install jsonasobj2 · libregistry