【问题标题】:composing Serializers + DSL组成序列化器 + DSL
【发布时间】:2016-03-11 04:56:35
【问题描述】:

我已经定义了自定义 Jackson 序列化程序,并且我有一个 Formats 范围以允许编写我的类型。

我想组合一个对象。一开始我试过:

val req =
  ("source" → asJValue(sources)) ~
  ("format" → asJValue(formats))

但这不起作用,因为 Formats 不适用于 asJValue。

所以我被困住了

val source = parse(write(sources))
val format = parse(write(formats))

val req =
  ("source" → source) ~
  ("format" → format)

我错过了什么吗? 谁能告诉我一个更好的方法?

谢谢,

【问题讨论】:

    标签: json4s


    【解决方案1】:

    此解决方案可能对您有用:

    import org.json4s.Extraction.decompose
    
    val req =
      ("source" → decompose(sources)) ~
      ("format" → decompose(formats))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-28
      • 1970-01-01
      • 2021-02-24
      相关资源
      最近更新 更多