thedevsaddam/gojsonq

From should support a variable-length argument to describe the path

jpap opened this issue · 1 comments

jpap commented

Thanks for a great package! :D

I am parsing JSON that uses a dot (".") for some key names. I've discovered that I could redefine the separator using gojsonq.SetSeparator("·") to a middle-dot, and then use fmt.Sprintf to define the path input to gojsonq.From.

What would be even better would be to avoid all of this, and just have From support multiple arguments, with each argument describing components of the path to the desired node. In this case, the separator can be ignored, and I don't have to use the middle dot setup as above.

For example, q.From("first.level.key.name", "data") would select the path:

  • first.level.key.name
    • data

where the first path component has dots in it, and the second path component does not.

At the moment, I have to do the following:

q.From(fmt.Sprintf("%s·%s", "first.level.key.name", "data"))

It seems can be done using fmt.Sprintf so why should we change the existing API?