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
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
@library("jsonAddProperties")
|
public fun Json.add(other: Json): Json {
|
||||||
public fun Json.add(other: Json): Json = noImpl
|
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 external interface JsonClass {
|
||||||
public fun stringify(o: Any): String
|
public fun stringify(o: Any): String
|
||||||
|
|||||||
@@ -340,14 +340,5 @@ Kotlin.arrayFromFun = function (size, initFun) {
|
|||||||
return result;
|
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;
|
Kotlin.identityHashCode = getObjectHashCode;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user