Install & Compatibility
Where this runs
tested against v0.0.2 · 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
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.004s · 19.2MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 2.4s · import 0.003s · 20MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
loads
✓ from jstyleson import loads
✗ import jstyleson
dumps
✓ from jstyleson import dumps
✗ import jstyleson
load
✓ from jstyleson import load
✗ import jstyleson
This quickstart demonstrates how to use `jstyleson.loads()` to parse a JSON string containing JavaScript-style comments and trailing commas. It then shows how `jstyleson.dumps()` can be used to serialize a Python dictionary back to a JSON string, leveraging the standard `json` module's capabilities for formatting.
import jstyleson
# Example JSON string with JS-style comments and a trailing comma
invalid_json_str = """
{
"name": "Alice", // User's name
"age": 30, /* Age in years */
"isStudent": false, // Trailing comment after an element
"interests": ["coding", "reading", "hiking"],
"contact": {
"email": "alice@example.com",
"phone": "123-456-7890", // Phone number
},
}
"""
try:
# Parse the JSON string with jstyleson
result_dict = jstyleson.loads(invalid_json_str)
print("Successfully parsed JSON:")
print(result_dict)
print(f"Type: {type(result_dict)}")
# You can also dump a Python dictionary back to a JSON string
json_output = jstyleson.dumps(result_dict, indent=2)
print("\nDumped JSON:")
print(json_output)
except Exception as e:
print(f"An error occurred: {e}")
Debug
Known issues
breakingThe library explicitly states support for Python 2.7 and 3.5. While it might work with newer Python versions, it is not officially tested or guaranteed due to its last update being in 2016. Users on Python 3.6+ should thoroughly test compatibility.fixThoroughly test `jstyleson` in your Python 3.6+ environment before relying on it in production. Consider alternative, actively maintained libraries for robust JSON parsing needs.
affects: <=0.0.2 with Python >=3.6
gotchaJStyleson is not actively maintained; its last release was in June 2016. This means there will be no new features, bug fixes, or security updates. Projects relying on this library should be aware of the potential for unaddressed issues.fixEvaluate whether the limited functionality provided by `jstyleson` is sufficient for your long-term needs. For robust and maintained solutions, consider alternatives like `json5` or custom pre-processing if complex JSON variations are required.
affects: 0.0.2
gotchaThe library's PyPI status is '3 - Alpha'. This indicates that it was never considered stable or production-ready by its developers. While it handles basic comment and trailing comma removal, its internal mechanisms might not be robust for all edge cases.fixUse with caution in production environments. Prioritize comprehensive testing of JSON inputs to ensure `jstyleson` behaves as expected for your specific use cases.
affects: 0.0.2
gotchaJStyleson primarily handles comments and trailing commas in JSON. It does *not* support other common JavaScript object literal features like unquoted property names (e.g., `{key: "value"}`) or single-quoted strings (e.g., `{'key': 'value'}`). It relies on the standard `json` module after sanitization, which requires strict JSON syntax for these elements.fixDo not expect `jstyleson` to parse JSON with unquoted keys or single-quoted strings. If these are present, pre-process your JSON string further or use a more comprehensive parser like `json5`.
affects: 0.0.2
Upgrade
Version history
0.0.2latest on PyPI · released Jun 21, 2016
Audit
Dependencies
No dependency data recorded yet.