RecordPlatformSpecific
Attributes
- Source
- RecordPlatformSpecific.scala
- Graph
-
- Supertypes
- Known subtypes
-
object Record
Members list
Value members
Concrete methods
Construct a record from a JavaScript object.
Construct a record from a JavaScript object.
Any nested type T
can be converted as long as a NativeConverter[T]
instance is given.
This operation is of course unsafe. Missing primitive fields become zeros or nulls and missing object fields yield java.lang.RuntimeException
.
Value parameters
- nc
-
a conversion type class
- obj
-
a JavaScript object
Attributes
- Returns
-
a record
- Example
-
import scala.scalajs.js val obj: js.Any = js.Dynamic.literal(name = "tarao", age = 3) val r = Record.fromJS[% { val name: String; val age: Int }](obj) // val r: com.github.tarao.record4s.%{val name: String; val age: Int} = %(name = tarao, age = 3)
- Source
- RecordPlatformSpecific.scala
Construct a record from a JSON string.
Construct a record from a JSON string.
Any nested type T
can be converted as long as a NativeConverter[T]
instance is given.
This operation is of course unsafe. Missing primitive fields become zeros or nulls and missing object fields yield java.lang.RuntimeException
.
Value parameters
- json
-
a JSON string
- nc
-
a conversion type class
Attributes
- Returns
-
a record
- Example
-
import scala.scalajs.js val json = """{"name":"tarao","age":3}""" val r = Record.fromJSON[% { val name: String; val age: Int }](json) // val r: com.github.tarao.record4s.%{val name: String; val age: Int} = %(name = tarao, age = 3)
- Source
- RecordPlatformSpecific.scala
Givens
Givens
Attributes
- Source
- RecordPlatformSpecific.scala
Extensions
Extensions
Convert this record to a JavaScript object
Convert this record to a JavaScript object
Any nested type T
can be converted as long as a NativeConverter[T]
instance is given.
Attributes
- Returns
-
a JavaScript object
- Example
-
val r = %(name = "tarao", age = 3) val obj = r.toJS // val obj: scala.scalajs.js.Any = [object Object]
- Source
- RecordPlatformSpecific.scala
Convert this record to a JSON string
Convert this record to a JSON string
Any nested type T
can be converted as long as a NativeConverter[T]
instance is given.
Attributes
- Returns
-
a JSON string
- Example
-
val r = %(name = "tarao", age = 3) val json = r.toJSON // val json: String = {"name":"tarao","age":3}
- Source
- RecordPlatformSpecific.scala