Skip to main content

CJSON is a data file format(inspired from JSON), but supports logical expressions too. Having extended language support to NodeJS, Python and Java, users has experienced data reusability. For features and examples, please refer to this documentation as base document.

Project description

CJSON Logo

Coded Javascript Object Notation


For Python


CJSON is a data file format(inspired from JSON), but supports logical expressions too. Having extended language support to NodeJS, Python and Java, users has experienced data reusability. For features and examples, please refer to this documentation as base document.


Python Tag
Test Status




Installation

pip install codedjson

Examples

Importing a JSON file in CJSON file

file.cjson

{
    "source": $import "path/to/source.json",
    "target": {
        "fruit": "Apple",
        "size": "Large",
        "color": "Red"
    }
}

Code

    from cjson import Cjson
    cjson = Cjson(file/path/to/file.cjson);
    var b = cjson.deserialize();

Output

{
    "source": {
        // source.json content
    },
    "target": {
        "fruit": "Apple",
        "size": "Large",
        "color": "Red"
    }
}

Calling relative keys using JPATH

Below example shows color variable is calling data from fruit variable

file.cjson

{
    "target": {
        "fruit": "Orange",
        "size": "Medium",
        "color": $.target.fruit
    }
}

Code

    from cjson import Cjson
    cjson = Cjson(file/path/to/file.cjson);
    var b = cjson.deserialize();

Output

{
    "target": {
        "fruit": "Orange",
        "size": "Medium",
        "color": "Orange"
    }
}

Single/ Multiple line comments

For single line comments, use //

For multi line comments, use like below:

// This is first line comment
// This is the second one

{
    "name": "Amrut" // This is not allowed
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codedjson-1.2.0.tar.gz (6.0 kB view details)

Uploaded Source

File details

Details for the file codedjson-1.2.0.tar.gz.

File metadata

  • Download URL: codedjson-1.2.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for codedjson-1.2.0.tar.gz
Algorithm Hash digest
SHA256 6bcef9b99e1cdda5ff97f9ab56f3fa55c30f9208aa7ed300ca940da28997cae5
MD5 0a230c7dcd371ca56a6c5dc4b295506d
BLAKE2b-256 ad99a6313c743a81af845f04e1f01fd5e550952e73ed3d0df85a12378c22c145

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page