mercredi 6 mai 2015

Ruby Sinatra - How to capture post json data and save to file

How do I capture a Json data from POST route and save it to file? I have simple ruby sinatra code as below.

#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
require 'json'

post '/' do
  values = JSON.parse(request.env["rack.input"].read)
# How do I save "values" of JSON to file..
end

Aucun commentaire:

Enregistrer un commentaire