-
Notifications
You must be signed in to change notification settings - Fork 0
Inheritance
Grisgram edited this page Oct 3, 2025
·
8 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/struct, #file:path/to/file, ... <commands>": { ... } }
inheritance sign: ::
command separator: ,
Note
#ref can be omitted
// some_file.json
{
"some_value": 80
}
{
"parent_struct": {
"some_value": "Hello World!"
}
"child_struct1::parent_struct": { // #ref was left out
"some_other_value": "#ref:parent_struct"
},
"child_struct2::parent_struct, #file:some_file": {},
"child_struct3::#file:some_file, parent_struct": {},
"child_struct4::#file:some_file, parent_struct": {
"some_value": "Hawkmax"
}
}Important
Inheritance may appear similar to the #join command,
but keep in mind that RichJSON Inheritance behaves very differently when it comes to reference data types
In particular:
- Child structs will never directly reference parent members
- Instead, values are copied, ensuring independency from the parent
// some_file.json
{
"some_value": 80
}
{
"parent_struct": {
"some_value": "Hello World!"
}
"child_struct1": { // parent_struct
"some_value": "Hello World!",
"some_other_value": { // #ref:parent_struct
"some_value": "Hello World!"
}
},
"child_struct2": { // parent_struct, #file:some_file
"some_value": 80
},
"child_struct3": { // #file:some_file, parent_struct
"some_value": "Hello World!"
},
"child_struct4": { // #file:some_file, parent_struct
"some_value": "Hawkmax"
}
}Author’s Recommendation: next read Interface
Back to Repo ● Wiki Home
Copyright © coldrock.games