Skip to content

Instantly share code, notes, and snippets.

@debuggerboy
Created September 5, 2025 10:16
Show Gist options
  • Select an option

  • Save debuggerboy/e47d9285b56d432d0ac25c654c50b4be to your computer and use it in GitHub Desktop.

Select an option

Save debuggerboy/e47d9285b56d432d0ac25c654c50b4be to your computer and use it in GitHub Desktop.
JQ single-quoted string error

JQ Help

Issue

When we get Invalid numeric literal error when on colon following a single-quoted string

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

Fix

jq has text manipulation support and a fromjson function so we can do something like:

$ echo "{'foo':'bar'}" | jq -R "gsub(\"'\"; \"\\\"\") | fromjson"
{
  "foo": "bar"
}

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment