now it is possible to use custon Json to load Module

This commit is contained in:
InsanusMokrassar 2020-02-13 20:55:20 +06:00
parent 2748c3f861
commit b3966beb32
2 changed files with 13 additions and 3 deletions

View File

@ -4,4 +4,7 @@ import kotlinx.serialization.ImplicitReflectionSerializer
import kotlinx.serialization.json.Json
@ImplicitReflectionSerializer
fun loadModule(json: String): Module = Json.nonstrict.parse(ModuleDeserializerStrategy, json)
fun Json.loadModule(json: String): Module = parse(ModuleDeserializerStrategy, json)
@ImplicitReflectionSerializer
fun loadModule(json: String): Module = Json.nonstrict.loadModule(json)

View File

@ -2,10 +2,17 @@ package com.insanusmokrassar.sdi
import kotlinx.io.InputStream
import kotlinx.serialization.ImplicitReflectionSerializer
import kotlinx.serialization.json.Json
import java.io.File
@ImplicitReflectionSerializer
fun loadModule(stream: InputStream) = loadModule(stream.reader().readText())
fun Json.loadModule(stream: InputStream) = loadModule(stream.reader().readText())
@ImplicitReflectionSerializer
fun loadModule(file: File) = loadModule(file.inputStream())
fun loadModule(stream: InputStream) = Json.nonstrict.loadModule(stream.reader().readText())
@ImplicitReflectionSerializer
fun Json.loadModule(file: File) = loadModule(file.inputStream())
@ImplicitReflectionSerializer
fun loadModule(file: File) = Json.nonstrict.loadModule(file.inputStream())