3 ms·
Sure, you can just use `js.Dynamic`, or write `trait`s describing the "schema" of your JSON, and of you go. Let's say you have have an array of Persons with a n
by sjrd 9y ago
Sure, you can just use `js.Dynamic`, or write `trait`s describing the "schema" of your JSON, and of you go. Let's say you have have an array of Persons with a name and age, you can type it as:
@ScalaJSDefined
trait Person extends js.Object {
var name: String
var age: Int
}
type Persons = js.Array[Person]
Done deal. With the new option `-P:scalajs:sjsDefinedByDefault` of this release, you don't even need the `@ScalaJSDefined`.
- AzzieElbab 9y agothanks -P:) awesome! takes circe out of the equation when talking to graphql which is already "typed"