3 ms·
Is there any way or anything in the works that would allow dealing with JSON without relying on libs that originated on JVM? They always feels like quite a bit
by AzzieElbab 9y ago
Is there any way or anything in the works that would allow dealing with JSON without relying on libs that originated on JVM? They always feels like quite a bit of an overkill considering that underlying platform is JS.
- sjrd 9y agoSure, 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"