part eight

Unit 8 JSON (De)Serialization

 

In unit 7, you have mastered how to represent asynchronous computations in Scala. In this unit, you’ll discover how to serialize and deserialize data in JSON format and how lazily represent side effects. In the capstone, you’ll complete the implementation of your quiz application by defining its business logic and HTTP API. In particular, you’ll learn about the following topics:

  • Lesson 48 shows you how to use a popular library called circe to convert a class into a JSON string and vice versa by defining JSON encoders and decoders.
  • Lesson 49 teaches you about lazy evaluation and how it differs from eager evaluation. You’ll see how by name parameters behave differently from by value ones. You’ll also discover how to lazily initialize a value using the lazy keyword.
  • Lesson 50 introduces you to the type IO from the library cats-effect to lazily evaluate both synchronous and asynchronous side effects.
  • Lesson 51 shows you how to apply the map and flatMap operations on an IO instance to manipulate and transform its value. You’ll also learn how to coordinate multiple side effects by running them in sequence or parallel.
  • Finally, you’ll define an HTTP server with an API that exposes and accepts data in JSON format in lesson 52. You’ll implement an app that picks ten questions for a given category and calculate a score based on the received answers.