From ebce2c4b839c0b2f8be78bc31c1ce12c45a0164c Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sat, 13 Oct 2018 03:37:40 +0200 Subject: Major refactoring of the multi-platform components. Dependencies upgrade. A lot of code style fixes. --- src/main/kotlin/pl/treksoft/kvision/utils/JSON.kt | 39 +++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/main/kotlin/pl/treksoft/kvision/utils/JSON.kt (limited to 'src/main/kotlin/pl/treksoft/kvision/utils/JSON.kt') diff --git a/src/main/kotlin/pl/treksoft/kvision/utils/JSON.kt b/src/main/kotlin/pl/treksoft/kvision/utils/JSON.kt new file mode 100644 index 00000000..e47351ac --- /dev/null +++ b/src/main/kotlin/pl/treksoft/kvision/utils/JSON.kt @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017-present Robert Jaros + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package pl.treksoft.kvision.utils + +import kotlinx.serialization.context.SimpleModule +import kotlinx.serialization.json.JSON +import pl.treksoft.kvision.types.DateSerializer +import kotlin.js.Date + +object JSON { + + val plain = JSON().apply { + install(SimpleModule(Date::class, DateSerializer)) + } + + val nonstrict = JSON(strictMode = false).apply { + install(SimpleModule(Date::class, DateSerializer)) + } + +} -- cgit