cjson module

class cjson.Cjson(content: str, is_content_cjson: bool = False)[source]

Bases: Is

Coded JSON is an extended format of JSON formatted data storage, which gives you more previledge to organize data into more structured format.

Here is an example for CJSON format:

{
    "source": $import "./source.json",
    "target": {
        "fruit": "Apple",
        "size": "Large",
        "color": "Red",
        "secColor": $.target.color,
        "colorList": [ $.target.color, $.target.secColor ],
        // You can add comments like this
        "digitCheck": 1.5,
        "digitImport": $.target.digitCheck,
        "digitArrayImport": [ $.target.digitCheck, $.target.digitImport ]
    }
}

The above CJSON snipped will be deserialized in JSON format and can be used as same as other JSON files.

For other details, please refer to official page: https://subhendushekhar.github.io/cjson/

deserialize()[source]

Deserializes CJSON context and returns dictionary object in JSON context.

Please Note, if any key is detected for runtime variable injections is replaced with <-tag->. No error/warning is thrown.

To inject runtime variables, use inject function

deserializeAsString()[source]

Deserializes CJSON content and returns content as string.

Content will be of pure JSON content and can be parsed as JSON

get_obj()[source]
get_string()[source]
inject(injecting_obj: dict)[source]
inject_with_key_value(key: str, value: str)[source]
json: Json | None = None
parse(jpath: str) any[source]
remove(key: str)[source]
replace(jpath: str, value: str)[source]
to_string() str[source]
cjson.is_content_json(content: str, is_file_path: bool = False)[source]

Checks if the parsed content is JSON