Kotlin 1.2.0 + Spring: create Web Application (3 of 4)


Here is continuation from Kotlin 1.2.0 + Spring: create Web Application (2 of 4).

Create View for Json

In Kotlin, mapOf defines Map and it can build object structure with similar appearance of JSON. Also, you can build JSON elements one by one with MutableMap.

Now use TaskJsonView in TaskController. Add the following methods to TaskController.

Launch the server and send JSON get request to http://localhost:8080/task, then the following response is returned. You must add "Accept=application/json" to the request header.

The data of success is built as {"data": { ... }}. This structure is basic and the same for all success JSON response. So export the frame into LayoutJsonView object.

And change list method in TaskJsonView object.

Continues to Kotlin 1.2.0 + Spring: create Web Application (4 of 4).