New Package: jsonian-mode reddit / emacs ---------------------------------------------------------------------- iwahbe · 2022-05-22 22:14 I wrote a new major mode called [jsonian- mode](https://github.com/iwahbe/jsonian) for editing JSON documents. `json-mode` has served me well for many years, but it doesn't hold up well on large documents. I wrote a new major mode `jsonian-mode` which parses only as necessary and minimizes the regex usage for syntax highlighting. This means that navigating very large files is faster. The `json-snatcher` (`jsonian-path`) function does not [blow its stack on large files](https://github.com/Sterlingg/json-snatcher/issues/9). It also includes a pretty nice utility for editing multi-line JSON strings (`jsonian-edit-string`). Since I use this regularly for work, and am maintaining it anyway, I figured other people might find it useful as well. Let me know if you find this useful. If you end up using `jsonian-mode` and find something wrong, please file an issue. ---------------------------------------------------------------------- whudwl · 2022-05-22 22:27 Thanks for sharing ---------------------------------------------------------------------- Imaproshaman · 2022-05-23 00:09 Sounds interesting. ---------------------------------------------------------------------- molteanu · 2022-05-23 05:15 How do you navigate your json files in your daily life? I have in mind something like smartparens. ---------------------------------------------------------------------- amanol · 2022-05-23 06:48 Thanks for sharing! From curiosity and only, what's the cons/pros to [json-tree- siter](https://github.com/tree-sitter/tree-sitter-json/tree/master) ? ---------------------------------------------------------------------- hkjels · 2022-05-23 07:09 Looks good! I'm switching now and will report back if I come across anything that's problematic. Thanks ---------------------------------------------------------------------- flyin1501 · 2022-05-23 14:58 This looks really nice! I'll have to try it out. Thank you for sharing it. Although, [you might want to add a license](https://choosealicense.com/no-permission/). ---------------------------------------------------------------------- iwahbe · 2022-05-24 07:26 That is a very good point. I have added one. ---------------------------------------------------------------------- iwahbe · 2022-05-24 07:35 I hadn't seen \`json-tree-siter\`. It looks like it only contains the grammar for JSON, not any emacs package built on top of it. If it's only a tree-sitter grammar, then it will (probably) paint slightly faster then \`jsonian-mode\`, but not support any more complex or emacs specific features like \`jsonian-path\` or \`jsonian-edit- string\`. If you wanted to, you could use \`jsonian-mode\` for additional features and \`json-tree-sitter\` for quick syntax highlighting. Since \`jsonian-mode\` uses syntax highlighting to to memoize string/key locations (which requires parsing to the beginning of the line) single line JSON analysis will probably be faster for \`jsonian-mode\` if tree-sitter-mode\` is also enabled. ---------------------------------------------------------------------- iwahbe · 2022-05-24 07:42 If they are sane `package.json` sized files, I mostly just jump by line number, not much magic there. The large json files that I navigate have unique keys which I generally navigate to via search. I often know in advance which key I have a problem with. The problem is I then need to know where I am in the file (structurally). That is what `jsonian-path` is for. [This](https://raw.githubusercontent.com/pulumi/pulumi-azure- native/master/provider/cmd/pulumi-resource-azure-native/schema.json) is an example of the kind of file I often spend time rooting about in. It is also why `jsonian-mode` works on arbitrarily large files.