Skip to content

Latest commit

 

History

History
56 lines (41 loc) · 1005 Bytes

README.md

File metadata and controls

56 lines (41 loc) · 1005 Bytes

Jackson

Sample project for Ktor demonstrating content negotiation feature using Jackson.

Running

Run this project with:

./gradlew :jackson:run

Use the following command scripts for testing:

curl -v --compress --header "Accept: application/json" http://localhost:8080/v1

Should respond with something like:

{
  "name" : "root",
  "items" : [ {
    "key" : "A",
    "value" : "Apache"
  }, {
    "key" : "B",
    "value" : "Bing"
  } ],
  "date" : [ 2018, 3, 2 ]
}

The result is pretty printed, to show off how to configure gson, but it is possible to use the default gson as well

Another test:

curl -v --compress --header "Accept: application/json" http://localhost:8080/v1/item/A

Response:

{
  "key": "A",
  "value": "Apache"
}

Using HTTP client

You can make requests to this sample server using Ktor HTTP client. See json-client sample.