从 Circe 中获取底层 HList
Get the underlying HList out from Circe
是否可以从 circe
而不是 JSON 中获取底层 hlist 表示?本质上将 case class 转换为 HList
注意:我知道这可以直接用 shapeless 实现,我想尝试 circe's
基于宏的解析器,因为我 运行 遇到 shapeless 的性能问题。
为什么你认为有"underlying hlist representation out from circe
"?
circe
所做的是parsing a String
into JSON, introducing type classes Decoder and Encoder
trait Encoder[A] extends Serializable { self =>
def apply(a: A): Json
//...
}
trait Decoder[A] extends Serializable { self =>
def apply(c: HCursor): Decoder.Result[A]
//...
}
和deriving these type classes using shapeless
. For example this means that if we have Decoder[H]
and Decoder[T]
then we have Decoder[H :: T]
. But there is no underlying circe
representation for a case class other than Json.
circe
不会将大小写 class 转换为 HList
,shapeless
会。
是否可以从 circe
而不是 JSON 中获取底层 hlist 表示?本质上将 case class 转换为 HList
注意:我知道这可以直接用 shapeless 实现,我想尝试 circe's
基于宏的解析器,因为我 运行 遇到 shapeless 的性能问题。
为什么你认为有"underlying hlist representation out from circe
"?
circe
所做的是parsing a String
into JSON, introducing type classes Decoder and Encoder
trait Encoder[A] extends Serializable { self =>
def apply(a: A): Json
//...
}
trait Decoder[A] extends Serializable { self =>
def apply(c: HCursor): Decoder.Result[A]
//...
}
和deriving these type classes using shapeless
. For example this means that if we have Decoder[H]
and Decoder[T]
then we have Decoder[H :: T]
. But there is no underlying circe
representation for a case class other than Json.
circe
不会将大小写 class 转换为 HList
,shapeless
会。