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

expected <string> but got <EOF> #2

Closed
Haffon opened this issue Feb 5, 2021 · 9 comments
Closed

expected <string> but got <EOF> #2

Haffon opened this issue Feb 5, 2021 · 9 comments

Comments

@Haffon
Copy link

Haffon commented Feb 5, 2021

This is the json file demo-blank-line.json content:

{
    "node_name" : "test_node",

    "log_valid_days" : 7
}

This is the jawk command line:
./jawk '{print _["log_valid_days"]}' demo-blank-line.json
and this is the command output:

demo-blank-line.json: expected <string> but got <EOF> (length 3) at input token 1
<<EOF>>

if I remove the blank line of demo-blank-line.json to make it look like this:

{
    "node_name" : "test_node",
    "log_valid_days" : 7
}

and run the same command line again, then it output:
7
My questions is:

  1. Why command failed just because of one blank line difference?
  2. Why need patch JSON.awk with patch-json-awk.diff?
  3. How can I use jawk with blank line json file?
@mohd-akram
Copy link
Owner

Thank you for this report! This is fixed in fc4f17c. To answer your questions:

  1. This was because of a bug in a modification I made to JSON.awk.
  2. To handle line-delimited JSON, and it's also needed for some other features in jawk.
  3. It should work now!

@Haffon
Copy link
Author

Haffon commented Feb 6, 2021

@mohd-akram Thanks, it work for simple json file now, but I have a little long json file, which cause the jawk command output:

some-long.json: expected <string> but got <EOF> (length 3) at input token 5
"type_id" : 1 , <<EOF>>

@mohd-akram
Copy link
Owner

Hmm, odd. Does this happen with JSON.awk too or just with jawk? Could you provide the file? If not, do you think you'd be able to reduce it to a small sample where the error happens?

@Haffon
Copy link
Author

Haffon commented Feb 6, 2021

@mohd-akram It does not happen with JSON.awk 1.4.2. I'm trying to reduce it to a small sample, see you soon.

@Haffon
Copy link
Author

Haffon commented Feb 6, 2021

The full file has another special character, which display as ^I when set option with :set list in vim, and it make a little hard for me to copy and paste the text. even to reduce it to a small sample.

@mohd-akram
Copy link
Owner

mohd-akram commented Feb 6, 2021

Hmm, okay. Could you paste the full error message that you get? I might be able to figure it out that way.

EDIT: It seems you did paste the full error but it got parsed in a strange way due to markdown. It's better to wrap errors/code in triple backticks, like so:

some-long.json: expected <string> but got <EOF> (length 3) at input token 5
"type_id" : 1 , <<EOF>>

Okay, I can reproduce the error now.

@mohd-akram
Copy link
Owner

This should be fixed in b5167c4.

@Haffon
Copy link
Author

Haffon commented Feb 6, 2021

Thanks for you fixing.

@mohd-akram
Copy link
Owner

Thanks for the reports!

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

No branches or pull requests

2 participants