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

Enhancement: Include the file name in parse error messaging #1553

Open
GreenGremlin opened this issue Dec 12, 2017 · 3 comments
Open

Enhancement: Include the file name in parse error messaging #1553

GreenGremlin opened this issue Dec 12, 2017 · 3 comments

Comments

@GreenGremlin
Copy link

It would be helpful if the filename were included in parse error messages. While this could fairly easily be handled by a script, it would be nice if this functionality was included in jq.

Example script

#!/usr/bin/env bash

set -e

for file in data/*.json; do
    some_data=$(jq . file)
done

Currently, a parse error produces the following output.

$ ./parse_data.sh
parse error: Expected another key-value pair at line 20, column 3

It would be helpful if it output something like this.

$ ./parse_data.sh
Error parsing file data/2017-10-data.json: Expected another key-value pair at line 20, column 3

Even better, this feature could be added behind a --verbose flag and include the context of the error.

$ ./parse_data.sh
Error parsing file data/2017-10-data.json:

  19 |    "name": "Bob Smith",
> 20 |   },
        ^
  21 |   {

Expected another key-value pair at line 20, column 3
@nicowilliams
Copy link
Contributor

I believe this is already so in master. 1.6 is coming.

@chbrown
Copy link

chbrown commented Mar 5, 2019

+1 for this enhancement 😄

Even on jq-1.6 (as reported by jq --version), parse errors still return the same filename-agnostic message.

@bf
Copy link

bf commented May 7, 2023

Still an issue in 2023. There should be a switch that includes the full file path in the erorr message.

This is especially a pain in the rear when processing thousands of small json files with jq in parallel fashion.

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

No branches or pull requests

5 participants