Path parts are concatenated with . or wrapped with [""] for object keys and wrapped in [] for array indices.
Example:
For state like this (cursor position is bold)
{"a": ["q", {"k": 1}, 1]}
Path would be a[1].k.
For JS like this
var a = {"b": {c: 4, daq: [5, 15]}}
var b = {q: [2, 1**2**]}
Path would be q[1].
NOTE: JS objects are not validated.
Using
Launch command Copy Json Path from command palette or context menu.
Configuration
extension.copyJsonPath.nonQuotedKeyRegex: regex that tests whether key in path can be used without quotes. If key matches - key is not quoted. Use it if you want to have path a.b-c instead of a[\"b-c\"] for example. If you want all keys to be escaped - use regex that doesn't match anything, e.g. single space will only match single space, which is very rare object key (you can go more complicated like a{1000}). Default is ^[a-zA-Z$_][a-zA-Z\\d$_]*$.
extension.copyJsonPath.putFileNameInPath: boolean to set if the file name should be in the path. Default is false.
extension.copyJsonPath.prefixSeparator: string separator to put between the prefix and the path. Default is :.
Linux dependency
xclip
Change Log
0.3.0
Add the option to put the file name in the returned path (@olivier-deschenes, #15)
0.2.1
Add info on regex for all keys to be escaped for nonQuotedKeyRegex (see issue #13)