Hi everyone, I've got a Kotlin project (not Andro...
# getting-started
a
Hi everyone, I've got a Kotlin project (not Android) that involves many variables with user-specific values (e.g. username, password, time-table) I would like this data to be moved out of the code, and into a modifiable file. The goal is to make it easy for non-coders to modify values and use the program. What are my best bets here? (JSON / YAML / etc). And what library should I be using? Here's a link to the project: https://github.com/adizcode/ProxyMate
t
In the past I’ve gone with Gson and/or Moshi, Kotlin serialization is an option as well, I have no experience with it though. As for the decision between json/yaml, I usually make that decision based on whether there will be repeated values in the data or not. If there is a lot of repeated data, with yaml the user can use anchors and aliases to make that easier to maintain. Otherwise go with json.
💡 1
👍 1
🙏 1
p
TOML is closer to plain text than JSON (less repeated quotes and braces and such) and has less footguns than YAML
👍 1
🤔 1
t
alternatively, if the config is simple… properties file?
2
a
Thank you for the responses. @Tim Oltjenbruns I don't actually know about properties files. Are they like .env files?
JVM-only, though it’d be easy enough to write a parser on another platform
a
This is great. I'll certainly read about using properties. Thanks :))
o
This excellent pure Kotlin config library together with YAML seems like a good option in my view: https://github.com/sksamuel/hoplite
1
💡 1
🙏 1