Added support for Firefox 3.1 beta 3's native JSON.
authorDan
Fri, 20 Mar 2009 09:15:00 -0400
changeset 873 285f0c6d9c9a
parent 872 8b42e51bb6e6
child 874 d67f43d93f30
Added support for Firefox 3.1 beta 3's native JSON.
includes/clientside/static/json.js
--- a/includes/clientside/static/json.js	Fri Mar 20 09:14:03 2009 -0400
+++ b/includes/clientside/static/json.js	Fri Mar 20 09:15:00 2009 -0400
@@ -11,6 +11,10 @@
 
 function toJSONString(input)
 {
+  if ( window.JSON )
+  {
+    return window.JSON.stringify(input);
+  }
   var m = {
           '\b': '\\b',
           '\t': '\\t',
@@ -142,6 +146,11 @@
 
 function parseJSON(string, filter)
 {
+  if ( window.JSON )
+  {
+    return window.JSON.parse(string);
+  }
+  
   try {
     if (/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.
             test(string))