Chapter 5. Handling JSON

This chapter covers

  • Consuming and producing JSON using the Scalatra JSON module
  • Handling heterogeneity when working with JSON
  • Using JSONP

JSON is a common data interchange format for semistructured data. It’s human-readable and supports primitive, array, and object values. Additionally, for web services it’s the natural data format of the browser, due to its close relationship with JavaScript.

Scalatra offers a module that supports an application working with JSON. This chapter covers its use with practical examples taken from the food domain. Who knows, maybe you’ll also learn a useful recipe!

5.1. Introducing JsonSupport

The Scalatra JSON module extends an application’s request handling with two facets:

Get Scalatra in Action now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.