6. A Simple JSON Server

The default data protocol of front-end JavaScript websites is JSON. When you’re writing a back-end service, handling JSON is becoming essential. This chapter will build a JSON server in ClojureScript.

In this recipe you use Clojure to create a simple JSON server. We create a new Clojure project, create an HTML page with JavaScript to post the JSON, and create a Clojure server in Compojure to receive the request and return a response. Then we’ll process and display that response in the HTML page’s JavaScript.

Assumptions

In this chapter we assume the following:

Image You know enough JavaScript to recognize a JSON post and receive ...

Get Clojure Recipes 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.