Use JSON.dump instead of .to_json.
require json
Fix specs.