From 8302879991bcdb1a70d9a69872f20a35f51bbd18 Mon Sep 17 00:00:00 2001 From: develar Date: Wed, 24 Jul 2013 13:13:56 +0400 Subject: [PATCH] JS backend: added reviver parameter to JSON.parse. Fixed code style in json.kt. (cherry picked from commit b3bf97c) --- js/js.libraries/src/core/json.kt | 29 +++++++++++------------- js/js.translator/testFiles/kotlin_lib.js | 2 +- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/js/js.libraries/src/core/json.kt b/js/js.libraries/src/core/json.kt index bb486e2706c..1b03de1fe68 100644 --- a/js/js.libraries/src/core/json.kt +++ b/js/js.libraries/src/core/json.kt @@ -1,33 +1,30 @@ package js -import java.util.*; import js.library native public class Json() { - + library("jsonGet") + fun get(parameterName: String): Any? + library("jsonSet") + fun set(parameterName: String, value: Any?): Unit } -library("jsonSet") -public fun Json.set(paramName : String, value : Any?) : Unit = js.noImpl +library("jsonFromTuples") +public fun json(vararg pairs: Pair): Json = js.noImpl -library("jsonGet") -public fun Json.get(paramName : String) : Any? = js.noImpl - -library("jsonFromPairs") -public fun json(vararg pairs : Pair) : Json = js.noImpl - -library("jsonFromPairs") -public fun json2(pairs : Array>) : Json = js.noImpl +library("jsonFromTuples") +public fun json2(pairs: Array>): Json = js.noImpl library("jsonAddProperties") -public fun Json.add(other : Json) : Json = js.noImpl +public fun Json.add(other: Json): Json = js.noImpl native public trait JsonClass { - public fun stringify(o: Any): String = noImpl - public fun parse(text: String): T = noImpl + public fun stringify(o: Any): String + public fun parse(text: String): T + public fun parse(text: String, reviver: ((key: String, value: Any?)->Any?)): T } native -public val JSON:JsonClass = noImpl \ No newline at end of file +public val JSON: JsonClass = noImpl \ No newline at end of file diff --git a/js/js.translator/testFiles/kotlin_lib.js b/js/js.translator/testFiles/kotlin_lib.js index 2a4ebda109b..ce2024fc1c2 100644 --- a/js/js.translator/testFiles/kotlin_lib.js +++ b/js/js.translator/testFiles/kotlin_lib.js @@ -532,7 +532,7 @@ var kotlin = {set:function (receiver, key, value) { return obj.toString(); }; - Kotlin.jsonFromPairs = function (pairArr) { + Kotlin.jsonFromTuples = function (pairArr) { var i = pairArr.length; var res = {}; while (i > 0) {