Bunny83 / SimpleJSON

A simple JSON parser in C#
MIT License
735 stars 294 forks source link

Create additional JSONTextMode #39

Open hybridherbst opened 3 years ago

hybridherbst commented 3 years ago

Currently, the default serialization produces "key" : "value" (note: two spaces) and the compact one produces "key":"value" (note: no space)

I'd like to see a third option here that produces another commonly seen format (the most common one I'm seeing at least): "key": "value" (note: single space after the colon).

https://github.com/Bunny83/SimpleJSON/blob/6fc562253ea16fbaa5d55202e525fc954a69da16/SimpleJSON.cs#L1009

I'd be happy to make a PR but wanted to

Bunny83 commented 3 years ago

Sorry for the late response. While I do understand that there are different styles out there, I don't really see a reason to change it. Changing the style may just cause trouble for some people who may have stored files locally and saved a hash of the content to detect changes.

A setting would be possible but there are too many different potential ways how you could format it. The framework has already outgrown the initial idea of being "simple" ^^. So I don't want to introduce tons of formatting settings and special cases.

hybridherbst commented 3 years ago

Understood.

(For some context: we were seeing this as an issue with tools that modify the manifest.json directly, which introduced a lot of version control noise since SimpleJSON changed every ": " to " : ". We have fixed that locally in that tooling but I thought it might be a reasonable request to have more "external" control over formatting here.)

Oh, and I think compared to nearly every other JSON library on the planet SimpleJSON is, indeed, very simple, and thus awesome for many use cases :)