~gpanders/ijq

fbf6a3d4a2e679f900183de053dfee0ff7bd2593 — Gregory Anders 4 months ago 72877bf
Surround keys containing special characters in quotes
1 files changed, 7 insertions(+), 0 deletions(-)

M main.go
M main.go => main.go +7 -0
@@ 40,6 40,10 @@ import (

const DefaultCommand string = "jq"

// Special characters that, if present in a JSON key, need to be quoted in the
// jq filter
const SpecialChars string = ".-:$"

var Version string

type Options struct {


@@ 346,6 350,9 @@ func createApp(doc Document) *tview.Application {

					entries := keys[:0]
					for _, k := range keys {
						if strings.ContainsAny(k, SpecialChars) {
							k = `"` + k + `"`
						}
						entries = append(entries, prefix+"."+k)
					}