kemal/docs/json.md
Fatih Kadir Akın 6c1dd90611 Create json.md
2015-12-04 13:54:12 +02:00

327 B

Serving JSON API

Just use to_json method to return.

require "kemal"
require "json"

# You can easily access the context and set content_type like 'application/json'.
# Look how easy to build a JSON serving API.
get "/" do |env|
  env.content_type = "application/json"
  {name: "Serdar", age: 27}.to_json
end