Validating json in ruby

Hi ,
Can anyone help me to know ,how to validate json format in ruby .

You could do something simple…

require ‘rubygems’
require ‘json’

def json_valid?(str)
JSON.parse(str)
return true
rescue JSON::ParserError
return false
end

Pradeepta S. wrote:

Hi ,
Can anyone help me to know ,how to validate json format in ruby .

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs