14

I am after a plugin or technique in sublime text 3 to get what I will call the fully qualified path of the json element that is selected in the editor window.

Somethink like: http://jsonpath.com/

I want to get a result somewhere that I can copy, I just want to use this for documentation, not programmatically. It does not need to be the https://github.com/jayway/JsonPath standard, just something that produces a readable/meaningful path to an element.

dreftymac
  • 31,404
  • 26
  • 119
  • 182
MattG
  • 5,589
  • 5
  • 36
  • 52
  • Are you looking to get a full path to the current cursor location in the json file, or are you looking to get results based on an object query from an input panel? [**JsonTree**](https://github.com/Flyclops/JsonTree) has some [**code**](https://github.com/Flyclops/JsonTree/blob/master/JsonTree.py) that you might be able to rework into a solution. Maybe create two additional arrays in parallel with `keys` & `trimkeys`, one that contains regions & another that contains the object's path. – Enteleform May 25 '16 at 04:22
  • I am after the "full path to the current cursor location in the json file". Will have a look at your suggestion, thanks. – MattG May 30 '16 at 06:32
  • @MattG did you ever find a solution? – sakurashinken Apr 12 '17 at 20:01
  • 1
    @sakurashinken, I switched to [Visual Studio Code](https://code.visualstudio.com/), which I prefer now anyway, and also use this extension: [JSONPath StatusBar](https://marketplace.visualstudio.com/items?itemName=richie5um2.vscode-statusbar-json-path) – MattG Sep 22 '17 at 13:56

2 Answers2

11

For those who came here looking for ST3 implementation of jsonpath, there's an awesome Pretty JSON plugin.

enter image description here

It has jQ integration, which does the same same thing as jsonpath. jQ has different syntax, but it's much more convenient to have this functionality available inside ST3 than to switch to browser.

voiger
  • 781
  • 9
  • 19
  • 1
    [jq](https://stedolan.github.io/jq/download/) should be installed manually; for Linux use command *sudo apt-get install jq* – vladimir Jul 22 '20 at 07:21
  • 1
    This is working on Windows, too. Simply download jq.exe and save to a directory in path. – Markus Jan 08 '22 at 13:21
9

I was searching for the same and ended up creating a plugin myself: https://github.com/akirk/StatusBarJsonPath

screenrecording of StatusBarJsonPath

akirk
  • 6,757
  • 2
  • 34
  • 57
  • Update: you can now get it via https://packagecontrol.io/packages/Status%20Bar%20JsonPath – akirk Jan 31 '23 at 16:00