scala - json4s: Convert type to JValue -


I want to get some source object src and a JValue

  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)}  

This is great if I Only want the last result, but I would like to write:

  def encodeJson (src: AnyRef): JValue  

It seems like I use I want to do, but I can not get an implementation for [AnyRef] (nor can I find Scaldeaux for it Json4s which only call me implementation).

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

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -