Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jpap opened this issue Aug 30, 2019 · 1 comment
Open

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

jpap opened this issue Aug 30, 2019 · 1 comment

Comments

@jpap
Copy link

jpap commented Aug 30, 2019

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"))
@thedevsaddam
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants