WebExtension JSON is not actually JSON
The current parser for WebExtension JSON assumes that it js JSON based, however it's not as it expects preparsing to strip comments:
Standards-compliant browsers are expected to ignore "//" comments. Disregarding comments, the manifest.json file format for browser extensions is expected to be fully JSON compliant.
See https://browserext.github.io/browserext/#manifest-json
This is going to be tricky - there doesn't seem to be any Python parser which would allow round trip - all just strip comments and then use standard json library.
Maybe https://pypi.org/project/json_tricks/
It doesn't support saving as well:
Since comments aren't stored in the Python representation of the data, loading and then saving a json file will remove the comments (it also likely changes the indentation).
Adapted from https://github.com/WeblateOrg/weblate/issues/2043#issuecomment-393633466:
When importing:
- Convert comments to some special JSON field so it can be represented in JSON, e.g. "// comment 1 2 3" to "{idSpecialComment_comment_1_2_3}"
- Exclude them from translations and only use them behind-the-scenes.
- When exporting (i.e. converting back to JSON) just do the same vice versa.
Any news?
No news, if there would be any news it would be written here.
https://pypi.org/project/jsoncparser/ might be actually a viable solution (at least it claims it supports saving as well)