Created
February 14, 2021 12:44
-
-
Save itang/58282f762731bf3ed8c26c06ba661c8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package example | |
import scala.scalajs.js | |
class C(val a: String, val b: Boolean, val c: Int) extends js.Object | |
object C { | |
def apply(a: String, b: Boolean, c: Int): C = new C(a, b, c) | |
} | |
case class D(name: String) extends js.Object | |
object Main { | |
def main(args: Array[String]): Unit = { | |
val c = C("itang", true, 30) | |
println(js.JSON.stringify(c, null.asInstanceOf[js.Array[js.Any]], 2)) | |
println(js.JSON.stringify(c)) | |
println(js.JSON.stringify(js.Dynamic.literal("name" -> "itang", "age" -> 30))) | |
println(js.JSON.stringify(js.Dynamic.literal(name = "itang", age = 30))) | |
val m = js.Dynamic.literal() | |
m.updateDynamic("name")("itang") | |
m.updateDynamic("age")(30) | |
println(js.JSON.stringify(m)) | |
val m2 = js.Object().asInstanceOf[js.Dynamic] | |
m2.updateDynamic("name")("itang") | |
println(js.JSON.stringify(m2)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment