KJS: reimplement Json.add in Kotlin

This commit is contained in:
Zalim Bashorov
2016-12-24 23:26:01 +03:00
parent edf1c2da0f
commit 20c482598a
2 changed files with 9 additions and 11 deletions
+9 -2
View File
@@ -13,8 +13,15 @@ public fun json(vararg pairs: Pair<String, Any?>): Json {
return res
}
@library("jsonAddProperties")
public fun Json.add(other: Json): Json = noImpl
public fun Json.add(other: Json): Json {
val keys: Array<String> = js("Object").keys(other)
for (key in keys) {
if (other.asDynamic().hasOwnProperty(key)) {
this[key] = other[key];
}
}
return this
}
public external interface JsonClass {
public fun stringify(o: Any): String
-9
View File
@@ -340,14 +340,5 @@ Kotlin.arrayFromFun = function (size, initFun) {
return result;
};
Kotlin.jsonAddProperties = function (obj1, obj2) {
for (var p in obj2) {
if (obj2.hasOwnProperty(p)) {
obj1[p] = obj2[p];
}
}
return obj1;
};
Kotlin.identityHashCode = getObjectHashCode;