bfrg / vim-jqplay

Run jq interactively in Vim
104 stars 5 forks source link

Error when using a large json file #10

Open MartinAskestad opened 5 months ago

MartinAskestad commented 5 months ago

I run for example curl -s https://openlibrary.org/search.json?q=Jules+Verne and I get a json document that is 27567 lines long. When I then run for example jq . openlibrary.json in command line everything seems to work fine and it prints the document to the screen.

But when I run this through vim-jqplay and the same query, I get the error // jq: parse error: Expected another array element at line 1935, column 13 but if I use curl -s https://openlibrary.org/search.json=ture+sventon as a data source vim-jqplay works as expected.

Is there a size limit to vim-jqplay?

bfrg commented 5 months ago

I run for example curl -s https://openlibrary.org/search.json?q=Jules+Verne and I get a json document that is 27567 lines long.

When I run this command, I get a json document that is 18656 lines long. I don't get any errors.

Is there a size limit to vim-jqplay?

No.

I have tested the plugin with a json document containing 56k lines and I had no issues.

Which OS and which vim version?

MartinAskestad commented 5 months ago

I'm using Windows 11 and Vim 9.1.

bfrg commented 5 months ago

jq: parse error: Expected another array element at line 1935, column 13

This looks like a jq error. This is not a Vim or vim-jqplay related error.

When you run the curl command, do you run it in git-bash? And which Vim do you use on Windows, Gvim or the one shipped with git-for-windows?

In Vim, what is the output of :set shell??

MartinAskestad commented 5 months ago

I run the command in plain old Windows command line, ie cmd.exe. The vim version I'm using is downloaded from https://github.com/vim/vim-win32-installer and the shell in vim is C:\WINDOWS\system32\cmd.exe.

I also think you are right, that the error message is from jq. And it seems like that it complains because the whole buffer isn't sent to jq. So perhaps the combination Windows and vim has a size limit? If I save my buffer as a file, does vim-jqplay use the path as parameter to jq or does it pipe the contents to it?

bfrg commented 5 months ago

If I save my buffer as a file, does vim-jqplay use the path as parameter to jq or does it pipe the contents to it?

The buffer is piped to jq. The jq job is started using Vim's job_start() function with the option 'in_buf'. This is explained in Vim's docs under :h in_buf.

It's either a Windows limitation or a Vim bug. I will look into it.