JSON to StrictDoc
A lightweight, zero-dependency bidirectional converter and parser between JSON and StrictDoc (.sdoc / .sgra).
Features
- Bidirectional Conversion: Convert
JSON <-> SDOCandJSON <-> SGRA. - Full StrictDoc Support: Document config (
OPTIONS,METADATA,VIEWS), custom[GRAMMAR], composite nodes ([[SECTION]],[[NODE]]), standard nodes ([TEXT],[REQUIREMENT]),[DOCUMENT_FROM_FILE], relations (Parent,Child,File), and inline[LINK]/[ANCHOR]. - Legacy Compatibility: Supports legacy
[SECTION]and[FREETEXT]blocks via--legacyand--legacy-json. - Built-in Validation: Validates syntax, field order, required fields, choice/tag types, and unique
UIDs.
Installation
pip install json-to-strictdoc
CLI Usage
# Convert JSON to SDOC (modern StrictDoc syntax)
json-to-strictdoc test.json test.sdoc
# Convert JSON to SDOC (legacy [SECTION] / [FREETEXT] syntax)
json-to-strictdoc --legacy test.json test_legacy.sdoc
# Convert SDOC to JSON
json-to-strictdoc test.sdoc output.json
# Convert SDOC to compact JSON (SECTIONS / REQUIREMENTS / FREETEXT)
json-to-strictdoc --legacy-json test.sdoc output_legacy.json
# Validate an .sdoc, .sgra, or .json file
json-to-strictdoc --validate test.sdoc
(You can also run the script directly with python3 strictdock-parser.py <input> <output>).
Python API
from strictdoc_parser import json_to_sdoc, sdoc_to_json, parse_sdoc, SDocValidator
# JSON -> SDOC
sdoc_text = json_to_sdoc(json_string)
# SDOC -> JSON
json_text = sdoc_to_json(sdoc_text)
# Parse into AST and validate
doc = parse_sdoc(sdoc_text)
SDocValidator.validate_document(doc)
Example
Input (test.json):
{
"TITLE": "Test Documentation",
"SECTIONS": [
{
"TITLE": "System Overview",
"FREETEXT": "This documentation is used to test the script",
"REQUIREMENTS": [
{
"UID": "TEST-01",
"TITLE": "Test the script",
"STATEMENT": "This is a Test",
"RATIONALE": "This is a test"
}
]
}
]
}
Generated Output (test.sdoc):
[DOCUMENT]
TITLE: Test Documentation
[[SECTION]]
TITLE: System Overview
[TEXT]
STATEMENT: >>>
This documentation is used to test the script
<<<
[REQUIREMENT]
UID: TEST-01
TITLE: Test the script
STATEMENT: >>>
This is a Test
<<<
RATIONALE: >>>
This is a test
<<<
[[/SECTION]]
Metadata
Release files for json-to-strictdoc 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| json_to_strictdoc-1.0.1.tar.gz | 34.9 kB | Without provenance | Details for json_to_strictdoc-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| json_to_strictdoc-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for json_to_strictdoc-1.0.1-py3-none-any.whl |
Total release size: 71.9 kB
Release files / json_to_strictdoc-1.0.1.tar.gz
| Download URL | json_to_strictdoc-1.0.1.tar.gz |
|---|---|
| Size | 34.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
16da783550df93753f9fa3f88a10b12bd20d9fc8b241b4b9ee612630a10f59d8
|
|
BLAKE2b-256 checksum How to use checksums |
2aff38f95a4a1b0d267aba5fecf5b29d4823bfcd8d2931512c80cfde9a2eacf2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.13
|
Release files / json_to_strictdoc-1.0.1-py3-none-any.whl
| Download URL | json_to_strictdoc-1.0.1-py3-none-any.whl |
|---|---|
| Size | 37.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d9238770a0527a1db55505de3dcbb498ef797bf8318a5dd2c78271ab258da16
|
|
BLAKE2b-256 checksum How to use checksums |
d9dafd1e6c7630471c103026331e6c0ced89afa3750e7ba02ad47caeb0284155
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.13
|
Security for json-to-strictdoc 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.