Created
March 2, 2012 06:25
-
-
Save rirakkumya/1956212 to your computer and use it in GitHub Desktop.
lift-jsonの一番簡単な使い方メモ #scala
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
libraryDependencies += "net.liftweb" %% "lift-json" % "2.4" |
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
import net.liftweb.json._ | |
import net.liftweb.json.Serialization.{read,write} | |
case class Foo(s:String, d:Int) | |
object Main extends App { | |
implicit val format = Serialization.formats(NoTypeHints) | |
val json = write(Foo("ddd",3)) | |
println(json, read[Foo](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
import net.liftweb.json._ | |
import net.liftweb.json.Serialization.{read,write} | |
import java.util.Date | |
case class Foo(s:String, d:Int, b:Bar) | |
case class Bar(o:Option[Int],l:List[Baz],date:Date) | |
case class Baz(d:Int) | |
object Main extends App { | |
implicit val format = Serialization.formats(NoTypeHints) | |
val json = write(Foo("ddd",3,Bar(Some(33),List(Baz(1),Baz(2),Baz(3)),new Date()))) | |
println(json, read[Foo](json)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
よく忘れるから書いとく