facelessuser / SerializedDataConverter

Convert between serialized data formats (plist | json | yaml)
Other
26 stars 4 forks source link

[Feature request] Save comments #13

Closed Kristinita closed 4 years ago

Kristinita commented 6 years ago

1. Request

It would be nice, if you add an option save_comments.

2. Justification

Yes, I know, that JSON files with comments not valid. But in configuring files for Sublime Text 3 as .sublime-settings or .sublime-commands comments are supported.

Write data in YAML much more convenient for human, than in JSON. I prefer to create Sublime Text configuring files in YAML. It would be nice, if would be possible to save comments, when converting, if "save_comments": true.

Thanks.

facelessuser commented 6 years ago

On the surface this may sound like a trivial addition, but the truth is, such a feature would be an enormous pain to implement.

We utilize the builtin json library, and the 3rd party PyYaml (I'm not going to get into plists right now). Both libraries are do not actively track comments. JSON don't use comments as part of the spec, and PyYaml completely abandons tracking comments as there is no functional use for them.

The only real solution is to essentially make my own parsers to track comments. While this would be fairly easy to track on the JSON side, PyYaml is a pain due to the complexity of its syntax.

In short, I like this project as I can easily utilize pre-existing libraries to parse the serialized data types and quickly convert them. I am not looking to spend time developing my own serialized parsers to preserve comments. It's just too much work and would eat up too much of my free time to implement.

Kristinita commented 6 years ago

PyYAML ready alternatives? Example.

Thanks.

facelessuser commented 6 years ago

What about JSON? What about PLIST? Unless there was a simple path to get comments in all three platforms, it just isn't worth the effort. I'm not looking to write any parsers, not just YAML. I just simply have too many projects, so I prioritize the kind of work I'm interested in pursuing.