Open pierrekttipay opened 5 months ago
I tested it and it's working as intended, if you set filetype to json
. Can you elaborate about the issue? what is the exact error?
Weird. I am on a .json
file, I do :set filetype=json
just to be sure.
I press Shift-V to select the entire line with the json I shared before.
Then press :
the prompt is autocompleting with:
:'<,'>
I delete and change it to :JsonFormatSelection
getting: marked text is not a valid json
On that same line, I tried :JsonFormatToken
instead just to test a little.
jq: parse error: Invalid string: control characters from U+0000 through U+001F must be escaped at line 43, column 11
Unfortunately I cannot reproduce your issue, I tested on separate Linux and Windows environments and both worked as intended(formatted as collapsed your given json with various commands).
Can you try and run :JsonFormatFile
on your original json code inside the new buffer? Or just save it into a file and run jq
on that file. if it still returns the error then problem is between your json and jq
I am on mac. that could be the issue:
running :JsonFormatFile
rewrite the entire file with
jq: parse error: Invalid string: control characters from U+0000 through U+001F must be escaped at line 43, column 11
running cat ./storage/logs/laravel.json | jq
on that file (outside of nvim) works well. The output is formatted by jq without error.
I think this issue will be solved if target json will be saved into file at first and then send it into jq
. All operations on windows are implemented similarly. Unfortunately I don't have any access on mac and won't be able to test the behaviour tho
this json is detected as invalid by json-nvim though it is perfectly valid