Sublime text 3 plugin to get JSON path
Asked Answered
P

2

15

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.

Pre answered 25/5, 2016 at 1:19 Comment(4)
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 has some code 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.Columbarium
I am after the "full path to the current cursor location in the json file". Will have a look at your suggestion, thanks.Pre
@Pre did you ever find a solution?Homogenesis
@sakurashinken, I switched to Visual Studio Code, which I prefer now anyway, and also use this extension: JSONPath StatusBarPre
K
12

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.

Kerry answered 17/5, 2019 at 13:21 Comment(3)
jq should be installed manually; for Linux use command sudo apt-get install jqSixfold
This is working on Windows, too. Simply download jq.exe and save to a directory in path.Lagasse
It's been already 2 years since there's a JQ plugin for Sublime. It's even more convenient than PrettyJSON.Kerry
K
12

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

screenrecording of StatusBarJsonPath

Kicker answered 21/5, 2021 at 18:13 Comment(1)
Update: you can now get it via packagecontrol.io/packages/Status%20Bar%20JsonPathKicker

© 2022 - 2024 — McMap. All rights reserved.