KJS: reimplement Json.add in Kotlin
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user