NativeConverter

@implicitNotFound("Could not find an implicit NativeConverter[${A}]")

Typeclass for converting between Scala.js and native JavaScript.

Type parameters:
A

the type to convert

Companion:
object
class Object
trait Matchable
class Any
object BooleanConv.type
object ByteConv.type
object CharConv.type
object DoubleConv.type
object FloatConv.type
object IntConv.type
object JSAnyConv.type
object JSDateConv.type
object LongConv.type
object NullConv.type
object ShortConv.type
object StringConv.type
object UUIDConv.type

Value members

Abstract methods

Convert a native Javascript type to Scala.js. Returns either A, or a String error.

Convert a native Javascript type to Scala.js. Returns either A, or a String error.

Concrete methods

def fromJson(json: String): A

Convert a Json String to type A. Returns either A, or a String error.

Convert a Json String to type A. Returns either A, or a String error.

def fromNative(nativeJs: Any): A

Convert a native Javascript type to Scala.js. Returns either A, or a String error.

Convert a native Javascript type to Scala.js. Returns either A, or a String error.

Extensions

Extensions

extension (a: A)
def toJson: String

Convert type A to a JSON string

Convert type A to a JSON string

def toNative: Any

Convert a Scala.js type to native JavaScript.

Convert a Scala.js type to native JavaScript.

This is an extension method, so it's available on all types that derive NativeConverter. To use for other types, like Int, summon a NativeConverter and use: NativeConverter[Int].toNative(123)