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.
pip install codedjson
{
"source": $import "path/to/source.json",
"target": {
"fruit": "Apple",
"size": "Large",
"color": "Red"
}
}
from cjson import Cjson
cjson = Cjson(file/path/to/file.cjson);
var b = cjson.deserialize();
{
"source": {
// source.json content
},
"target": {
"fruit": "Apple",
"size": "Large",
"color": "Red"
}
}
Below example shows color
variable is calling data from fruit
variable
{
"target": {
"fruit": "Orange",
"size": "Medium",
"color": $.target.fruit
}
}
from cjson import Cjson
cjson = Cjson(file/path/to/file.cjson);
var b = cjson.deserialize();
{
"target": {
"fruit": "Orange",
"size": "Medium",
"color": "Orange"
}
}
{
"target": {
"types": "asd",
"fruit": <fruit>,
"quantity": <quantity>,
},
"jsonInjection": <jsonTypeData>
}
cjson = Cjson(variable_injection)
injec_data = {
"fruit": "apple",
"quantity": 1,
"jsonTypeData": {
"secondaryData": {
"type": "fruit",
"seeds": "yes"
}
}
}
data = cjson.inject(injecting_obj=injec_data)
{
"target": {
"types": "asd",
"fruit": "apple,
"quantity": 1,
},
"jsonInjection": {
"secondaryData": {
"type": "fruit",
"seeds": "yes"
}
}
}
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
}