Skip to content

#ref (reference)

Hawkmax edited this page Oct 3, 2025 · 13 revisions

Description

The reference command is one of the core commands which is the reason why RichJSON became so highly modular in the first place and also the origin of every other command that followed after. It is very important to get this command right, but no pressure, it is very straight forward.

Syntax

mem: { "key": "#ref:<path>" }
key: no implementation

Param(s)

path: Define the path to a member like this 'my/path/to/member', the path needs to be absolut starting from current root.

Example

Before Apply

{ // <-- root
    "some_struct": {
        "some_array": [ 0, 1, 2, 3 ],
        "some_string": "hi I am a string:)"
    },
    // in the above line the `#ref` command is going reference the member `some_array` of the struct 'some_struct'
    "ref_array": "#ref:some_struct/some_array",
    "ref_string": "#ref:some_struct/some_string",
    "ref_struct": "#ref:some_struct"
}

After Apply

Note

The term reference here depends on the data type.
Depending on the type, the given member may or may not be truly referenced.

{
    "some_struct": {
        "some_array": [ 0, 1, 2, 3 ],
        "some_string": "hi I am a string:)"
    },
    "ref_array": [ 0, 1, 2, 3 ],                 // "#ref:some_struct/some_array"
    "ref_string": "hi I am a string:)",          // "#ref:some_struct/some_string"
    "ref_struct": {                              // "#ref:some_struct"
        "some_array": [ 0, 1, 2, 3 ],
        "some_string": "hi I am a string:)"
    }
}

Author’s Recommendation: next read #global

Clone this wiki locally