0

I have a very very big JSON and I'd like to check the path to some keys. Pretty printing doesn't help if the JSON is very large and lot of hierarchies. I'm using Sublime 3 and jq together with the Pretty JSON plugin. Is there a way to know the full path(s) to a given key using the jq tool or any other way? I could write a JSON parser in some language and do it but I need just to figure out quickly where things are.

peak
  • 105,803
  • 17
  • 152
  • 177
SkyWalker
  • 13,729
  • 18
  • 91
  • 187

1 Answers1

1

It would be easier to answer more precisely if you can provide a small sample of your data and the desired output but in any event the --stream option may be what you want. From the documentation:

Streaming

With the --stream option jq can parse input texts in a streaming fashion, allowing jq programs to start processing large JSON texts immediately rather than after the parse completes. If you have a single JSON text that is 1GB in size, streaming it will allow you to process it much more quickly.

However, streaming isn’t easy to deal with as the jq program will have [<path>, <leaf-value>] (and a few other forms) as inputs.

Here are some existing answers you may want to review.

The JQ Cookbook also has an example:

Community
  • 1
  • 1
jq170727
  • 13,159
  • 3
  • 46
  • 56