StreetComplete icon indicating copy to clipboard operation
StreetComplete copied to clipboard

Change config data from YAML to JSON

Open FloEdelmann opened this issue 1 year ago • 7 comments

Part of

  • #5415

FloEdelmann avatar Jan 14 '24 16:01 FloEdelmann

Hmm, so you decided to not give net.mamoe.yamlkt a chance but default to making all config files JSON. In the linked topic, there was one issue with JSON and that was the inability to have comments in it.

Are all these files free of comments, so we actually do not need comments?

westnordost avatar Jan 14 '24 20:01 westnordost

Are all these files free of comments, so we actually do not need comments?

It looks like: Yes, free of comments, except all these abbreviations.yml. And the note "Do not edit, this file is autogenerated".

westnordost avatar Jan 21 '24 21:01 westnordost

I actually prefer JSON over YAML, because YAML – while looking easy and simple – is actually a complex and sometimes counter-intuitive data format, see the yaml document from hell. Also, getting rid of the YAML parser would decrease the app size a little, which would be nice. That's why I didn't look into yamlkt at all until now.

Now I did and it looks like kamlkt doesn't have a decodeFromStream function, which means there would need to be a bit of refactoring (but nothing too bad) anyway.

FloEdelmann avatar Jan 29 '24 18:01 FloEdelmann

Yeah, YAML kind of gets constant flak.

westnordost avatar Jan 29 '24 19:01 westnordost

I actually prefer JSON over YAML, because YAML – while looking easy and simple – is actually a complex and sometimes counter-intuitive data format, see the yaml document from hell.

Well, if we write our own files then possibility of creating insane constructs is lesser problem. If we would be getting external data then this would be a good reason to expect them in JSON.

And JSON has big flaws of banning trailing comma and missing comment support. Where JSON is much worse when you try to document something (comment needs to be stuffed into nonfunctional fields, ugly diffs).

matkoniecz avatar Jan 30 '24 06:01 matkoniecz

And JSON has big flaws of banning trailing comma and missing comment support. Where JSON is much worse when you try to document something

What about jsonc or json5?

HolgerJeromin avatar Jan 30 '24 09:01 HolgerJeromin

Things that need comments could be defined in YAML or TOML in e.g. /res/ or in a different repo, such as it is done for the countrymetadata (do we need languagemetadata?) and then translated to JSON in a build job.

I think there are not that many things that actually need comments. See https://github.com/streetcomplete/StreetComplete/pull/5444#issuecomment-1902764607

westnordost avatar Jan 30 '24 15:01 westnordost

kaml now supports multiplatform native (starting with the upcoming release)

westnordost avatar Jul 03 '24 16:07 westnordost