How to get JSON path in syntaxTree

Hi, I am trying to get the path for an iteration of a syntaxTree in CodeMirror v6. I have this code:

syntaxTree(view.state)
      .cursor()
      .iterate((node) => {
        console.log(view.state.doc.sliceString(node.from, node.to));
      });

which loops through a syntax tree and outputs the JSON attributes. However, this doesn’t give the path to the node. Outputting node.name gives values like JsonText, PropertyName, Object, Property, and not a JSON path.

I am trying to output the path of the current node. So if I had JSON like {"names": ["example"]} on an iteration that outputs "example" I would get names[0]. Is there a way to do this?

Following .parent pointers might be what you want. (Though you might want to use a SyntaxNode rather than a stateful cursor for that.)