-
Notifications
You must be signed in to change notification settings - Fork 0
Inheritance
0xMaxLab edited this page Mar 15, 2026
·
4 revisions
When used correctly, this is where the real magic happens.
Inheritance is one of the main reasons why RichJSON is so highly modular and efficient at reducing redundancy.
Let me introduce you to you RichJSON's Multi-Inheritance!
mem: no implementation
key: { "key::$ref:path/to/object, $file:path/to/file, ... <commands>": { ... } }
inheritance sign: ::
command separator: ,
Note
$ref can be omitted
// some_file.json
{
"some_value": 80
}
{
"parent_object": {
"some_value": "Hello World!"
}
"child_object1::parent_object": { // $ref was left out
"some_other_value": "$ref:parent_object"
},
"child_object2::parent_object, $file:some_file": {},
"child_object3::$file:some_file, parent_object": {},
"child_object4::$file:some_file, parent_object": {
"some_value": "Hawkmax"
}
}Important
Inheritance may appear similar to the $merge command,
but keep in mind that RichJSON Inheritance behaves very differently when it comes to reference data types
In particular:
- Child objects will never directly reference parent members
- Instead, values are copied, ensuring independency from the parent
// some_file.json
{
"some_value": 80
}
{
"parent_object": {
"some_value": "Hello World!"
}
"child_object1": { // parent_object
"some_value": "Hello World!",
"some_other_value": { // $ref:parent_object
"some_value": "Hello World!"
}
},
"child_object2": { // parent_object, $file:some_file
"some_value": 80
},
"child_object3": { // $file:some_file, parent_object
"some_value": "Hello World!"
},
"child_object4": { // $file:some_file, parent_object
"some_value": "Hawkmax"
}
}Author’s Recommendation: next read Advanced Key Syntax
Back to Repo ● Wiki Home
Copyright © Maximilian Schwarz