Replies: 9 comments
-
Yes, I am open to that idea. Maybe also JSON5. Before we do, I would like to see a little proof of concept first to see how this impacts the editor and what it requires. |
Beta Was this translation helpful? Give feedback.
-
Yes, json5 is what we need
|
Beta Was this translation helpful? Give feedback.
-
😎 nice to see this repl. Yeah, so I think what is needed to make the editor work with multiple JSON variants:
|
Beta Was this translation helpful? Give feedback.
-
Can we use the existing [from what I understand] more-performant AST when possible and only use the new one as-needed, with some prompt/warning for documents >500mb? @josdejong, if you could suggest starting point(s) for the requirements you detailed, feel free to post them and I can try to make some headway. Otherwise I'll try to dedicate some time regardless if I'm able, but I'm not familiar with e.g. syntax trees; I mostly have experience with object-oriented and shell/nix programming. |
Beta Was this translation helpful? Give feedback.
-
I think we'll first have to do a small experiment to get an idea of how much work it will be (I expect a lot), and if it can be performant. Good to know: the predecessor of |
Beta Was this translation helpful? Give feedback.
-
Ah I see, I misread your point. This is a stupid question, but surely there's a method for formatting JSON5 in a performant way, given that e.g. VSCode does it. Why is this situation different? (Not saying it isn't, to be clear, genuinely interested to know.) |
Beta Was this translation helpful? Give feedback.
-
There are few parsers for json5 and they are not very fast (the difference is several or several dozen times). Useful links: |
Beta Was this translation helpful? Give feedback.
-
Thanks for the list with JSON5 parsers @AlexRMU, that can be useful.
It is a good question @Sinjai . That VSCode can do it doesn't mean that it is trivial to make it working 😉. To give a bit of context:
I expect that support for JSON5 requires parsing the code into a full AST, and I expect that naively parsing an AST is probably slow and may blow up memory for documents of 500MB. I doubt if there is a parser that can load and AST partially and lazily. So that may be a challenge, and indeed we may need to build a custom JSON5/JSON parser. Alternatively, we can accept that JSON5 can only work with small documents, and we can build an hybrid system that can use the JSON5 parser and the fast JSON parser + internal model side by side. To do that, we need to create an interface to interact with the document, and use that everywhere we want to read something from the document or operate on it. I think that may be the best option, but we need to be really careful: the complexity of that can easily explode, it will be a huge refactoring, and it will be a challenge to make it performant. It will require an experiment first to see what difficulties we come across. I'm also not sure how to render for example comments in |
Beta Was this translation helpful? Give feedback.
-
Moving this idea to the Discussions > Ideas section since we are not actively working on it. |
Beta Was this translation helpful? Give feedback.
-
Add support for JSONC (JSON with comments) and non-strict JSON (JS objects), for example via the check mark in the settings
(of course, technically it's not JSON)
Beta Was this translation helpful? Give feedback.
All reactions