The Scala Toolkit

Handling JSON with uPickle

Language

uPickle is a lightweight serialization library for Scala.

It includes uJson, a JSON manipulation library that can parse JSON strings, access or mutate their values in memory, and write them back out again.

uPickle can serialize and deserialize Scala objects directly to and from JSON. It knows how to handle the Scala collections such as Map and Seq, as well as your own data types, such as case classs and Scala 3 enums.

Using Scala CLI, you can require the entire toolkit in a single line:

//> using toolkit latest

Alternatively, you can require just a specific version of UPickle:

//> using dep com.lihaoyi::upickle:3.1.0

In your build.sbt file, you can add the dependency on the Toolkit:

lazy val example = project.in(file("example"))
  .settings(
    scalaVersion := "3.2.2",
    libraryDependencies += "org.scala-lang" %% "toolkit" % "0.1.7"
  )

Alternatively, you can require just a specific version of UPickle:

libraryDependencies += "com.lihaoyi" %% "upickle" % "3.1.0"

In your build.sc file, you can add the dependency to the upickle library:

object example extends ScalaModule {
  def scalaVersion = "3.2.2"
  def ivyDeps =
    Agg(
      ivy"org.scala-lang::toolkit:0.1.7"
    )
}

Alternatively, you can require just a specific version of UPickle:

ivy"com.lihaoyi::upickle:3.1.0"

Contributors to this page: