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

decode,interp: Don't shadow _key and error on missing _key #757

Merged
merged 1 commit into from
Sep 3, 2023

Conversation

wader
Copy link
Owner

@wader wader commented Sep 3, 2023

For fromjson and other "value" decode values fq make then behave both like a normal jq value and decode value. This is to make tobytes, format etc work. Before all _* would be treated as special keys. Now they are first looked up in the wrapped value and then as decode values.

Also now ._key that don't exist reutrn null instead of throw error.

$ fq -n '{"_format": 123} | fromjson | ._format' Now:
123
Before:
"json"

$ fq -n '{} | fromjson | ._missing'
Now:
null
Before
error

For fromjson and other "value" decode values fq make then behave both like
a normal jq value and decode value. This is to make tobytes, format etc work.
Before all _* would be treated as special keys. Now they are first looked up in
the wrapped value and then as decode values.

Also now ._key that don't exist reutrn null instead of throw error.

$ fq -n '`{"_format": 123}` | fromjson | ._format'
Now:
123
Before:
"json"

$ fq -n '`{}` | fromjson | ._missing'
Now:
null
Before
error
@wader wader merged commit 699c03f into master Sep 3, 2023
5 checks passed
@wader wader deleted the decode-ext-key-shadow branch September 3, 2023 08:58
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 this pull request may close these issues.

None yet

1 participant