草庐IT

json - 使用 circe 递归地将 JSON 树转换为其他格式(XML、CSV 等)

为了使用circe将JSON节点转换为JSON以外的其他格式(如XML、CSV等),我想出了一个解决方案,我必须访问circe的内部数据结构。这是我将JSON转换为XML字符串的工作示例(并不完美,但您明白了):packageio.circeimportio.circe.Json.{JArray,JBoolean,JNull,JNumber,JObject,JString}importio.circe.parser.parseobjectSampleextendsApp{deftransformToXMLString(js:Json):String=jsmatch{caseJNull=

json - 如何在不消除对象歧义的情况下使用 circe 解码 ADT

假设我有这样的ADT:sealedtraitEventcaseclassFoo(i:Int)extendsEventcaseclassBar(s:String)extendsEventcaseclassBaz(c:Char)extendsEventcaseclassQux(values:List[String])extendsEventcirce中Decoder[Event]实例的默认泛型派生期望输入JSON包含一个包装器对象,该对象指示表示哪个案例类:scala>importio.circe.generic.auto._,io.circe.parser.decode,io.circe

json - 如何在不消除对象歧义的情况下使用 circe 解码 ADT

假设我有这样的ADT:sealedtraitEventcaseclassFoo(i:Int)extendsEventcaseclassBar(s:String)extendsEventcaseclassBaz(c:Char)extendsEventcaseclassQux(values:List[String])extendsEventcirce中Decoder[Event]实例的默认泛型派生期望输入JSON包含一个包装器对象,该对象指示表示哪个案例类:scala>importio.circe.generic.auto._,io.circe.parser.decode,io.circe