用换行解析json

时间:2018-04-27 16:10:08

标签: json crystal-lang

鉴于Json是这样的:

{
  "description": "foo \n bar"
}

如果我尝试使用Hash(String, String)方法创建from_json,我会收到以下错误:

Unexpected char '
' at 1:22 (JSON::ParseException)

如何正确解析它?

require "json"

Hash(String, String).from_json(%({"description": "foo \n bar"}))

https://play.crystal-lang.org/#/r/3ynh

0 个答案:

没有答案