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

Invalid numeric literal error when the input preceded by non-json line #2403

Closed
arbitrary-dev opened this issue Jan 28, 2022 · 4 comments
Closed
Labels
Milestone

Comments

@arbitrary-dev
Copy link

Describe the bug
There's an invalid numeric literal error when the input preceded by non-json line.

To Reproduce

$ cat broken.json; echo -n "\nJQ output:\n\n"; jq -Rr 'fromjson // .' broken.json
dummy
{"wat-da":100}
{"work-dat":"100"}

JQ output:

jq: error (at broken.json:1): Invalid numeric literal at EOF at line 1, column 5 (while parsing 'dummy')
jq: error (at broken.json:2): Invalid numeric literal at line 1, column 14 (while parsing '{"wat-da":100}')
{
  "work-dat": "100"
}

$ cat moved.json; echo -n "\nJQ output:\n\n"; jq -Rr 'fromjson // .' moved.json  
{"wat-da":100}
{"work-dat":"100"}
dummy

JQ output:

{
  "wat-da": 100
}
{
  "work-dat": "100"
}
jq: error (at moved.json:3): Invalid numeric literal at EOF at line 1, column 5 (while parsing 'dummy')

Expected behavior

$ cat broken.json; echo -n "\nJQ output:\n\n"; jq -Rr 'fromjson // .' broken.json
dummy
{"wat-da":100}
{"work-dat":"100"}

JQ output:

jq: error (at broken.json:1): Invalid numeric literal at EOF at line 1, column 5 (while parsing 'dummy')
{
  "wat-da": 100
}
{
  "work-dat": "100"
}

Environment (please complete the following information):

  • OS and Version: Gentoo Linux
  • jq version:
$ jq --version
jq--

$ equery l jq
* Searching for jq ...
[IP-] [  ] app-misc/jq-1.7_pre20201109:0
@wader
Copy link
Member

wader commented Jan 28, 2022

Seems similar to #2400?

@arbitrary-dev
Copy link
Author

Could be.

@thalman
Copy link
Contributor

thalman commented Mar 31, 2022

It is definitely connected. I just tested it and #2400 fixes this issue too.

@itchyny itchyny added the bug label Jun 3, 2023
@itchyny itchyny added this to the 1.7 release milestone Jun 25, 2023
@itchyny
Copy link
Contributor

itchyny commented Jun 28, 2023

This bug was fixed by #2400 (c4d39c4).

@itchyny itchyny closed this as completed Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants