Platinum Partner

Check If String Has JSON Inside

Two very simple methods of checking whether string has JSON inside ...

More accurate one:


module JSON
  def is_json?(string)
    begin
      parse(string).all?
    rescue ParserError
      false
    end
  end
end


Less accurate one (but quicker):


class String
  def is_json?
    self[0..0] == '{'
  end
end
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}