1
我有一個問題,我使用其餘的webservice而不是返回一個json格式不正確,有時返回一個字符串,有時在同一個字段中返回一個整數。這是該格式的代碼:播放2個Json格式,捕獲Int或字符串
implicit val ItemFormat: Format[Item] = (
(JsPath \ "a").format[String] and
(JsPath \ "b").format[String] and
(JsPath \ "c").formatNullable[String]
)(Item.apply , unlift(Item.unapply))
如果c爲空或不存在,或者是一個字符串效果很好,但如果c爲我有這樣的錯誤: ValidationError(名單(error.expected。 jsstring),WrappedArray()))
我會得到,如果c是一個整數,或者轉換成字符串或者把C =無