You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If json keys are kebab case ("last-name"), it's natural to try something like
jq '.last-name'
which emits a confusing error message:
jq: error: name/0 is not defined at <top-level>, line 1:
this seems like a common enough problem that it might be worth making a special error message for expressions that look like that.
(alternatively, the jq language could support kebab-case literals. this might break some scripts, but it seems unlikely that anyone would deliberately write an expression that looks like kebab-case)
The text was updated successfully, but these errors were encountered:
Looking for the function is done in the compilation phase, and it is difficult (or making the code messy) to tell that the function is the right hand side of a binary expression which has indexing in the left hand side and .... Also can we know the difference between .last - name and .last-name in the compilation phase?
it looks to me like it wouldn't be too hard to add a heuristic check at the point of the error message. check if the source expression looks like unquoted skewer case, and suggest that might be the problem. I might have time/energy to write a POC patch this weekend
For context me and @felix9 talked a bit about this on mastodon https://fosstodon.org/@[email protected]/113455083464066624 specially that there is two cases, a compile time and runtime time case, and probably the compile time case is more common and might be an easier case for heuristics?
If json keys are kebab case ("last-name"), it's natural to try something like
which emits a confusing error message:
this seems like a common enough problem that it might be worth making a special error message for expressions that look like that.
(alternatively, the jq language could support kebab-case literals. this might break some scripts, but it seems unlikely that anyone would deliberately write an expression that looks like kebab-case)
The text was updated successfully, but these errors were encountered: