Unciv/core/src/com/unciv/JsonParser.kt
Yair Morgenstern 4c51e70283 Managed to load first mini mod, needs some work before this can work for users
(what happens if we started a game with mod A and then we want to start a game with only mod B?)
2019-12-31 17:49:07 +02:00

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)
}
}