【发布时间】:2015-04-19 14:30:09
【问题描述】:
一个 JSON 字符串:
{
"name": "Mike",
"age": 111
}
案例类:
case class User(name:String, age:Int)
如果我使用 scala,有很多库可以让我将 JSON 转换为 case 类,反之亦然,但它们不能在 scala.js 中使用。
如何在 scala.js 中完成这项工作?
【问题讨论】:
一个 JSON 字符串:
{
"name": "Mike",
"age": 111
}
案例类:
case class User(name:String, age:Int)
如果我使用 scala,有很多库可以让我将 JSON 转换为 case 类,反之亦然,但它们不能在 scala.js 中使用。
如何在 scala.js 中完成这项工作?
【问题讨论】:
【讨论】:
Prickle的作者是我的朋友……
Circe 拥有超过 1000 颗星:
https://github.com/circe/circe
【讨论】:
更安全有效的选择是:
下面是来自the Twitter API 的a message sample 的benchmarks for parsing and serialization 的结果:
【讨论】: