diff --git a/adapter/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/adapter/tools/tlc/TlcAdapter.kt b/adapter/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/adapter/tools/tlc/TlcAdapter.kt index 6815d23..4a0d0e4 100644 --- a/adapter/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/adapter/tools/tlc/TlcAdapter.kt +++ b/adapter/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/adapter/tools/tlc/TlcAdapter.kt @@ -19,6 +19,10 @@ import de.fraunhofer.iem.kpiCalculator.model.adapter.tlc.TlcDefaultConfig import de.fraunhofer.iem.kpiCalculator.model.adapter.tlc.TlcDto import de.fraunhofer.iem.kpiCalculator.model.kpi.KpiId import de.fraunhofer.iem.kpiCalculator.model.kpi.RawValueKpi +import kotlinx.serialization.ExperimentalSerializationApi +import kotlinx.serialization.json.Json +import kotlinx.serialization.json.decodeFromStream +import java.io.InputStream sealed class TechLagResult { data class Success(val libyear: Long) : TechLagResult() @@ -27,6 +31,16 @@ sealed class TechLagResult { object TlcAdapter { + private val jsonParser = Json { + ignoreUnknownKeys = true + explicitNulls = false + } + + @OptIn(ExperimentalSerializationApi::class) + fun dtoFromJson(jsonData: InputStream): TlcDto { + return jsonParser.decodeFromStream(jsonData) + } + fun transformDataToKpi( data: Collection, config: TlcConfig = TlcDefaultConfig.get() diff --git a/model/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/model/adapter/tlc/TlcDefaultConfig.kt b/model/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/model/adapter/tlc/TlcDefaultConfig.kt index 12d5b39..a802695 100644 --- a/model/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/model/adapter/tlc/TlcDefaultConfig.kt +++ b/model/src/main/kotlin/de/fraunhofer/iem/kpiCalculator/model/adapter/tlc/TlcDefaultConfig.kt @@ -44,4 +44,4 @@ object TlcDefaultConfig { ) ) } -} \ No newline at end of file +}