Is there precedence for object oriented syntax for a relative path?

Viewed 8

I'm creating my own extended version of JSON for various reasons. One thing that I'm adding is the ability to self reference and I'm trying to come up with an OO syntax for relative paths.

To illustrate, lets say I have a nested object that is supposed to reference its parent object

{ my_item: { parent: ??? } }

??? symbolizes the missing syntax.

Now in most operating systems, going up one level is notated as .. so we could try doing the same

{ my_item: { parent: .. } }

Looks pretty neat, however, if I tried to reference anything else in the parent, I'd end up with

{ my_item_sibling: {}, my_item: { sibling_of_parent: ...my_item_sibling } }

Which is not as neat as its the same as spread syntax ... which I'm also adding

I could do something with parentheses, like so

{ my_item_sibling: {}, my_item: { sibling_of_parent: (..).my_item_sibling } }

Which is not terrible but I'd prefer something cleaner.

Maybe I'll reserve a symbol?

{ my_item_sibling: {}, my_item: { sibling_of_parent: #.my_item_sibling } }

In any case, these examples are just to illustrate what I'm doing. If there is an established or a particularly nice looking way to do it, I'll just copy that.

The question is: Is there a precedence to this? A relative path implemented in a c-like language?

0 Answers
Related