Skip to content

Commit

Permalink
Add JsValue#show JsValue#showPretty
Browse files Browse the repository at this point in the history
  • Loading branch information
chungonn committed Jul 7, 2024
1 parent 7e09c74 commit 216d9c7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name := "commons-json"

organization := "com.greenfossil"

version := "1.0.14-RC1"
version := "1.0.14-RC2"

scalaVersion := "3.3.3"

Expand Down
12 changes: 12 additions & 0 deletions src/main/scala/com/greenfossil/commons/json/JsValue.scala
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,18 @@ sealed trait JsValue extends Dynamic:

def prettyPrint: String = Json.prettyPrint(this)

transparent inline def showPretty: JsValue =
val s = s"\n--------------\nJson Start\n--------------\n${this.prettyPrint}\n------------\nJson End\n------------\n"
show(Console.out, s)

transparent inline def show: JsValue =
val s = s"\n--------------\nJson Start\n--------------\n${this.stringify}\n------------\nJson End\n------------\n"
show(Console.out, s)

transparent inline def show(s: java.io.PrintStream, any: Any): JsValue =
s.println(any)
this

def encodeBase64URL: String = encodeBase64URL("UTF-8")

def encodeBase64URL(charSet: String): String = encodeBase64URL(charSet, false)
Expand Down

0 comments on commit 216d9c7

Please sign in to comment.