Created
July 29, 2013 06:05
-
-
Save akehoyayoi/6102407 to your computer and use it in GitHub Desktop.
json4s(lift-json)がバグってる件
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "org.json4s" %% "json4s-native" % "3.2.4" | |
import org.json4s._ | |
import org.json4s.native.Serialization._ | |
case class AAA(a : Option[Long],b : Option[Long],c : Option[Long]) | |
object JsonTest { | |
def toJson[Value <: AnyRef](any : Value) : String = { | |
write(any)(DefaultFormats) | |
} | |
} | |
/* | |
scala> JsonTest.toJson(AAA(Some(1),Some(2),Some(3))) | |
res0: String = {"a":1,"b":2,"c":3} | |
scala> JsonTest.toJson(AAA(Some(1),Some(2),None)) | |
res1: String = {"a":1,"b":2} | |
scala> JsonTest.toJson(AAA(Some(1),None,Some(3))) | |
res2: String = {"a":1,"c":3} | |
scala> JsonTest.toJson(AAA(None,Some(2),Some(3))) | |
res3: String = {,"b":2,"c":3} // <- wrong format | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment