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 class
s and Scala 3 enum
s.
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("."))
.settings(
scalaVersion := "3.3.4",
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.3.4"
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:
Contents
- Introduction
- Testing with MUnit
- How to write tests?
- How to run tests?
- How to run a single test?
- How to test exceptions?
- How to write asynchronous tests?
- How to manage the resources of a test?
- What else can MUnit do?
- Working with files and processes with OS-Lib
- How to read a directory?
- How to read a file?
- How to write a file?
- How to run a process?
- What else can OS-Lib do?
- Handling JSON with uPickle
- How to access values inside JSON?
- How to modify JSON?
- How to deserialize JSON to an object?
- How to serialize an object to JSON?
- How to read and write JSON files?
- What else can uPickle do?
- Sending HTTP requests with sttp
- How to send a request?
- How to construct URIs and query parameters?
- How to send a request with a body?
- How to send and receive JSON?
- How to upload a file over HTTP?
- What else can sttp do?
- Building web servers with Cask
- How to serve a static file?
- How to serve a dynamic page?
- How to handle query parameters?
- How to handle user input?
- How to use websockets?
- How to use cookies and decorators?