Say I have a case class:
case class Name(first: String, last: String)
val n1 = Name("John", "Doe")
val n2 = Name("Mary", "Doe")
and I have a java script object:
@js.native
trait MyJSObject extends js.Object {
def add(name: js.Object): Unit = js.native
}
such that name should be of the format
{"first":"John","last":"Doe"}
What is the best way to convert my case object to a js.Object?
I know this can be achieved doing a upickle.write() to convert it to a json String so I guess my question is is this the best way?