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

Retrieving the root value #149

Closed
aeneasr opened this issue Jan 13, 2020 · 0 comments · Fixed by #150
Closed

Retrieving the root value #149

aeneasr opened this issue Jan 13, 2020 · 0 comments · Fixed by #150

Comments

@aeneasr
Copy link
Contributor

aeneasr commented Jan 13, 2020

The JSON Pointer specification allows to retrieve the root value of a JSON document using the pointer #/. I was unable to figure out how to do that with GJSON paths. Is this currently possible?

I've tried several approaches but was unable to get the root element (I know that this is jj and not gjson but since one uses the other I assume that the inputs would return the same output for gjson too):

% echo '{"name":{"first":"Tom","last":"Smith"}}' | jj '.'

% echo '{"name":{"first":"Tom","last":"Smith"}}' | jj '' 

% echo '{"name":{"first":"Tom","last":"Smith"}}' | jj '*'     
{"first":"Tom","last":"Smith"}

I was unable to figure this out using the docs, but maybe I missed it.

aeneasr added a commit to ory/gjson that referenced this issue Jan 13, 2020
This modifier returns the current element as-is and can be used
to retrieve the JSON document itself. It is equivalent to the `#/` JSON Pointer.

Closes tidwall#149
aeneasr added a commit to ory/gjson that referenced this issue Jan 20, 2020
This modifier returns the current element as-is and can be used
to retrieve the JSON document itself. It is equivalent to the `#/` JSON Pointer.

Closes tidwall#149
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

Successfully merging a pull request may close this issue.

1 participant