Skip to content
This repository
Browse code

Add helpers to write in pretty JSON format

  • Loading branch information...
commit 560aa5eedcc8bf3ed986582a6db057d95fe3fb09 1 parent 102499e
Joni Freeman authored
10 core/json/src/main/scala/net/liftweb/json/Serialization.scala
@@ -42,6 +42,16 @@ object Serialization {
42 42 def write[A <: AnyRef, W <: Writer](a: A, out: W)(implicit formats: Formats): W =
43 43 Printer.compact(render(Extraction.decompose(a)(formats)), out)
44 44
  45 + /** Serialize to String (pretty format).
  46 + */
  47 + def writePretty[A <: AnyRef](a: A)(implicit formats: Formats): String =
  48 + (writePretty(a, new StringWriter)(formats)).toString
  49 +
  50 + /** Serialize to Writer (pretty format).
  51 + */
  52 + def writePretty[A <: AnyRef, W <: Writer](a: A, out: W)(implicit formats: Formats): W =
  53 + Printer.pretty(render(Extraction.decompose(a)(formats)), out)
  54 +
45 55 /** Deserialize from a String.
46 56 */
47 57 def read[A](json: String)(implicit formats: Formats, mf: Manifest[A]): A =

0 comments on commit 560aa5e

Please sign in to comment.
Something went wrong with that request. Please try again.