JSON-java
JSON-java copied to clipboard
Feature request: more formatting control: e.g. multi-line output even if only 1 key exists (same as major IDEs)
My current use case is to programmatically edit app.json.
This project config file is usually manually edited. Another example would be package.json.
It typically has only a single key 'expo'.
I cannot use this library without preserved key order and without the output format matching that of most IDEs.
Diffs are useless and I cannot commit any edited file like this.
I currently workaround this limitation by subclassing JSONObject and JSONTokener, but would of course prefer to see this functionality in the library.
Formatting: https://www.npmjs.com/package/vscode-json-languageserver
@rhoehener Thanks for bringing up this issue. The project is currently in maintenance mode, which limits the changes that can be accepted. Please see the FAQ for more details. If you have something that is compatible with the FAQ guidance, feel free to submit a pull request for it.
@rhoehener Some reasonable implementation of optional formatting should be possible. Can you provide an example of what your preferred output would look like?
@stleary I tried to describe my use case in detail in my first comment: I'm trying to programmatically edit json "config" files. Since config files are often under version control, the goal is to to keep the key order stable and to have the same formatting as used by the IDE (JetBrains, Eclipse, XCode etc). I'm not sure exactly what kind of formatting they use but at least some of them seem to use the "VSCode JSON Language Server" for this purpose.
tldr: format so that after edit the commit diff only marks the edited line, and not the whole file.
@rhoehener If you have something that formats the JSON for printing more or less correctly for you, please share it. Maybe there is some way we can incorporate it as an option.
Closed due to lack of activity.