OSDN Git Service

add json parser on common
[pettanr/pettanr.git] / lib / common.rb
diff --git a/lib/common.rb b/lib/common.rb
new file mode 100644 (file)
index 0000000..44ebcdf
--- /dev/null
@@ -0,0 +1,14 @@
+require 'json'
+
+module JSON
+  def self.parse_no_except(data)
+    res = data
+    begin
+      res = JSON.parse(data) if data.is_a?(String)
+    rescue 
+      return false
+    end
+    res
+  end
+end
+