jsoncrack.com icon indicating copy to clipboard operation
jsoncrack.com copied to clipboard

Ability to copy path to node

Open nils-jansen opened this issue 3 years ago • 5 comments
trafficstars

Feature

When clicking on a node, display the option to copy the path to that node to the clipboard. Possibly next to the "Clipboard" button: image

Alternative solutions or implementations

No response

Other context

No response

nils-jansen avatar Sep 23 '22 07:09 nils-jansen

hey, I can take care, could you clarify/confirm criteria?

My suggestion:

  1. add UI button (the same color as in clipboard + no icon)
  2. click to the button will will replace all clipboard data to path to the displayed node as a string with format TODO)

Alternative: we can display path to the node in the node modal header with clipboard button there

eLeontev avatar Oct 02 '22 14:10 eLeontev

What exactly is meant by path here?

AykutSarac avatar Oct 04 '22 17:10 AykutSarac

Example:

{ "one": { "two": { "three": 4 } } }

The path for "4" would be one.two.three.

nils-jansen avatar Oct 09 '22 16:10 nils-jansen

Example:

{ "one": { "two": { "three": 4 } } }

The path for "4" would be one.two.three.

I faced the limitation for expected result:

  • in the editor we have term "node" - it's represented as a independent block of data. In your example we don't have node 4 but we have node {three: 4}

image

so the expected result will be one.two instead of one.two.three

not sure if it's achievable at all since all editor designed for this type of data representation. @AykutSarac please confirm

btw workaround to achieve the result is: { "one": { "two": { "three": [4] } } } in this case 4 will be represented as a node and path to it will be one.two.three

p.s. current api cannot handle element position by it's index, so in example {"prop": [1, 2, {c: [3]}]} path for 3 is prop.c

eLeontev avatar Nov 03 '22 12:11 eLeontev

I think we can wait for #251 to be merged first, it changes whole parsing algorithm.

AykutSarac avatar Nov 03 '22 14:11 AykutSarac