mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-06 09:08:17 +07:00
![Yair Morgenstern](/assets/img/avatar_default.png)
(what happens if we started a game with mod A and then we want to start a game with only mod B?)
17 lines
509 B
Kotlin
17 lines
509 B
Kotlin
package com.unciv
|
|
|
|
import com.badlogic.gdx.Gdx
|
|
import com.badlogic.gdx.files.FileHandle
|
|
import com.badlogic.gdx.utils.Json
|
|
|
|
class JsonParser {
|
|
|
|
private val json = Json().apply { ignoreUnknownFields = true }
|
|
|
|
fun <T> getFromJson(tClass: Class<T>, filePath: String): T = getFromJson(tClass, Gdx.files.internal(filePath))
|
|
|
|
fun <T> getFromJson(tClass: Class<T>, file: FileHandle): T {
|
|
val jsonText = file.readString(Charsets.UTF_8.name())
|
|
return json.fromJson(tClass, jsonText)
|
|
}
|
|
} |