uPickle : Comparison with other Json Serialiers

Table of contents
Reading Time: 2 minutes

In my previous blog, I talked about how uPickle works. Now I will be comparing it will many other json serializers where I will be serializing and deserializing scala case class.

Before that let me discuss all the json serializers that I have used in my comparison. I will compare uPickle with PlayJson, Circe and Argonaut.

You can get all the code that I will explain in my github repository. Now, let’s see the code:

case class Product(brand: String, model : String)

object Product {
  implicit val playJsonFormatter  = Json.format[Product]     //For PlayJson
  implicit def uPickleFormatter: ReadWriter[Product] = macroRW  //For uPickle
  implicit def PersonCodecJson =
    casecodec2(Product.apply, Product.unapply)("brand", "model")   //For Argonaut

This is the case class which contains all the implicit JSON formatters.

Now lets take a product object for our examples and a json string that will be de-serialized back to product object.

val product = Product("Samsung", "12JF3DE")
val jsonString = "{\"brand\":\"Samsung\",\"model\":\"12JF3DE\"}"

Play JSON Serializer

To serialize the above case class.

val playJson = Json.toJson(product)

To deserialize the above case class.

val myPickle = Json.parse(jsonString).as[Product]

Argonaut JSON Serializer

To serialize

val argonautJson: Json = product.asJson

To deserialize

val parsed: Option[Product] = jsonString.decodeOption[Product]

Circe JSON Serializer

To serialize

val circeJson = product.asJson.noSpaces

To deserialize

val myPickle = decode[Product](jsonString)

uPickle JSON Serializer

To serialize

val upickleJson = write(product)

To deserialize

val upickleJson = read[Product](jsonString)


After comparing all these uPickle is faster than all these. See the screenshot below.


We can see that the execution time of uPickle is less both in serializing and deserializing.

Try it Yourself from here.

In my next blog I will talk about uJson which is the subset of uPickle and will talk about how we can transform it to other json serializers.

Happy reading….!!


uPickle Documentation


Written by 

I am a Software Consultant at Knoldus Inc. I am a Scala Enthusiast. I am familiar with Object Oriented Programming Paradigms, and has also worked upon .NET based technologies. Aside from being a programmer, I am familiar with NoSQL database technologies such like Cassandra. I also worked on Lagom microservice architecture.

1 thought on “uPickle : Comparison with other Json Serialiers2 min read

Comments are closed.