Created
March 6, 2015 17:30
-
-
Save lab3/a0045a92f551fa3fe7a6 to your computer and use it in GitHub Desktop.
json4s generic
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
package com.len.Boot | |
import org.json4s._ | |
import org.json4s.native.Serialization | |
import org.json4s.native.Serialization.{read, write} | |
object Boot { | |
implicit val formats = DefaultFormats + FieldSerializer[item[String]]() | |
def main(args: Array[String]): Unit ={ | |
val tmp = new item[String]("g").asInstanceOf[myGeneric[String]] | |
println(write(tmp)) | |
} | |
class item[T](value: T) extends myGeneric[T]{ | |
var genericField: T = value | |
var otherField = "other" | |
var customField = "custom" | |
} | |
trait myGeneric[T]{ | |
var genericField: T | |
var otherField: String | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment