Emacs Asked by a_subscriber on December 17, 2020
Emacs 26.1. Windows 10
It’s has function json-pretty-print
. But it not enough for me.
Has any another better json formater and validator?
I mean the next.
Suppose I has error on json on line 26. I missed “,”.
But json-pretty-print
get me strange error message:
Json readtable error: 93
I don’t understand this message. What does it mean?
Why simple not get message something like this:
Error: Parse error on line 26:
...n1_FR" } ] } "loyalty": true, "u
-------------------^
Expecting 'EOF', '}', ',', ']', got 'STRING'
So that is the reason why I need better json validator and formater.
I'm really curious about why you feel json-pretty-print
is not good enough.
Perhaps you don't like needing to call it manually? You could set it to run whenever you save the file:
(add-hook
'json-mode-hook
(lambda ()
(add-hook 'before-save-hook 'json-pretty-print-buffer t t)))
If you'd still like an alternative, I highly recommend prettier-mode. It's a minor mode that runs the file through prettier on save. In circumstances with invalid JSON it does give you diagnostic output (but does not enforce strict JSON AFAIK. For example:
prettier errors:
[error] stdin: SyntaxError: Unexpected token, expected "," (4:7)
[error] 2 | "foo": {
[error] 3 | "bar": "baz"
[error] > 4 | "blah": "blooh"
[error] | ^
[error] 5 | }
[error] 6 | }
[error] 7 |
Answered by ebpa on December 17, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP