Validate JSON

Check if a string is valid JSON.

Code

General
require 'json'
begin
  JSON.parse(str)
  return true
rescue
  return false
end

Parameters

The string to validate as JSON

Server

More Ruby Snippets