scala - json4s: Convert type to JValue -
I want to get some source object This is great if I Only want the last result, but I would like to write: It seems like I use I want to do, but I can not get an implementation for [AnyRef] src
and a JValue
(nor can I find Scaldeaux for it Json4s which only call me implementation).
def encodeJson (src: AnyRef): string = {import org.json4s.NoTypeHints Import Organ .json4s.JsonDSL.Double._ import org.json4s.jackson.JsonMethods._Import org.json4s.jackson.Serialization Import org.json4s.jackson.Serialization.write Underlying Val Format = Serialization.formats (NoTypeHints) Write ( Src)}
def encodeJson (src: AnyRef): JValue
The answer is org.json4s extraction
- this is a method Decomposed (A: Any) (built-in format: form ts): JValue
:
def encodeJson (src: AnyRef): JValue = {import org.json4s. {Extraction, NoTypeHints} Import org.json4s.JsonDSL.WithDouble._ Import org.json4s.jackson.Serialization Built-in Val Format = Serialization.formats (NoTypeHints) Extraction.decompose (src)}
< / Div>
Comments
Post a Comment