使用lift-json

时间:2017-04-15 15:11:33

标签: json scala lift-json

我得到的地图如下: Map(reference -> Map(scriptRenderings -> List(Map(text -> महा-सुभाषित-सङ्ग्रहे 9979, scheme -> null, startLetter -> म)), jsonClass -> QuoteText, metre -> None, key -> महा-सुभाषित-सङ्ग्रहे9979, language -> Map(code -> UNK))) 来自我的couchdb-lite数据库库。

  • 我需要将它们转换为案例类I've defined。我如何做到这一点(最好使用我已经使用的lift-json)?
  • 以及如何将此地图转换为JSON对象? (基本上是扭转this。)

1 个答案:

答案 0 :(得分:0)

我最终最终将地图转换为字符串并将字符串解析为案例类:

    val jsonStr = Serialization.writePretty(jsonMap)
//    log debug jsonStr
    val quoteText = Serialization.read[QuoteText](jsonStr)