jqlang / jq

Command-line JSON processor
https://jqlang.github.io/jq/
Other
30.5k stars 1.58k forks source link

"Invalid Numeric Literal" on colon following a single-quoted string (incorrect parser error message) #501

Closed bartgrantham closed 1 month ago

bartgrantham commented 10 years ago

EDIT (20150416): I KNOW IT'S INVALID JSON. THE BUG IS ABOUT THE NONSENSICAL ERROR MESSAGE

I get this from absent-mindedly and incorrectly using single-quotes:

$ echo "{'foo':'bar'}" | jq .foo
parse error: Invalid numeric literal at line 1, column 7

This is under 1.3. Trying to reproduce under 1.4, but after 5 minutes of trying to build from source I'm just going to submit this and move on.

wader commented 1 month ago

Unrelated to this issue but jq has text manipulation support and a fromjson function so one can do something like:

$ echo "{'foo':'bar'}" | jq -R "gsub(\"'\"; \"\\\"\") | fromjson"
{
  "foo": "bar"
}
bartgrantham commented 1 month ago

Glorious day! The decade-old issue is resolved!