salat是否支持scala中Either类型的de/serialization?

Does salat support de/serialization of type Either in scala?

我有以下情况类:

case class DataEntity
(
  name: String,
  value: Either[Complex, String]
)
case class Complex (x: String, y: String)

据我所知,序列化(写入 MongoDB)进行得很好,但反序列化失败了:

com.novus.salat.util.ToObjectGlitch: 

  argument type mismatch

  $anon(class catalog.DataEntity @ com.novus.salat.global.package$$anon@3fa48431) toObject failed on:
  SYM: catalog.DataEntity
  CONSTRUCTOR
public catalog.DataEntity(java.lang.String,scala.util.Either<catalog.Complex, java.lang.String>)

---------- CONSTRUCTOR EXPECTS FOR PARAM [0] --------------
NAME:         name
TYPE:         java.lang.String
DEFAULT ARG   [Missing, but unnecessary because input value was supplied]
@Ignore       false
---------- CONSTRUCTOR INPUT ------------------------
TYPE: java.lang.String
VALUE:
TESTTEXT
------------------------------------------------------------


---------- CONSTRUCTOR EXPECTS FOR PARAM [1] --------------
NAME:         value
TYPE:         scala.util.Either<catalog.Complex, java.lang.String>
DEFAULT ARG   [Missing, but unnecessary because input value was supplied]
@Ignore       false
---------- CONSTRUCTOR INPUT ------------------------
TYPE: com.mongodb.BasicDBList
VALUE:
[ [ "File" , "/bin/ls" ...
------------------------------------------------------------

上面的输出与上面的简化案例 类 手动匹配。 我正在使用 salatDAO 读取和写入数据库。

当前不支持

Either。我相应地更新了 "Supported Types" wiki。

请注意,在 Salat 1.10.0-SNAPSHOT 中,您将收到如下错误(尝试从 JSON 字符串反序列化时):

scala> SalatExamples.eitherHolder()
serialized EitherHolder(Left(data)) to { "_typeHint" : "com.novus.salat.examples.EitherHolder" , "either" : [ "data"]} for storage in mongo

com.novus.salat.json.UnsupportedJsonTransformationException: serialize: Unsupported JSON transformation for class='scala.util.Left', value='Left(data)'

NOTE: salat has certain limitations. It cannot deserialize JSON into case classes having fields such as:
- Arrays such as Array[String]
- Nested collections such as Map[String, List[String]]
- Optional collections such as Option[List[String]]

For more information, please visit: https://github.com/salat/salat/wiki/SupportedTypes

https://github.com/salat/salat/wiki/SupportedTypes

另请参阅:https://github.com/noahlz/salat-examples/blob/master/src/main/scala/com/novus/salat/examples/SalatExamples.scala