Browse Source

jsonformat bug fix

Alien 12 years ago
parent
commit
6e09a986ab

+ 1 - 1
chrome/manifest.json

@@ -1,6 +1,6 @@
 { 
 	"name": "WEB前端助手(FeHelper)", 
-	"version": "3.7",
+	"version": "3.8",
     "manifest_version": 2,
 	 
 	"default_locale": "zh_CN", 

+ 1 - 1
chrome/online.manifest.json

@@ -1,6 +1,6 @@
 {
     "name": "WEB前端助手(FeHelper)",
-    "version": "3.7",
+    "version": "3.8",
     "manifest_version": 2,
 
     "default_locale": "zh_CN",

+ 8 - 2
chrome/static/js/jsonformat/contentscript-jsonformat.js

@@ -74,11 +74,17 @@ baidu.csJsonFormat = (function(){
 
         // 是json格式,可以进行JSON自动格式化
         if(typeof jsonObj == "object") {
+            try{
+                // 要尽量保证格式化的东西一定是一个json,所以需要把内容进行JSON.stringify处理
+                source = JSON.stringify(jsonObj);
+            }catch(ex){
+                // 通过JSON反解不出来的,一定有问题
+                return;
+            }
+
             $('body').html(_htmlFragment);
             _loadCss();
             JsonFormatEntrance.clear();
-            // 要尽量保证格式化的东西一定是一个json,所以需要把内容进行JSON.stringify处理
-            source = JSON.stringify(jsonObj);
             JsonFormatEntrance.format(source);
 
             // 如果是JSONP格式的,需要把方法名也显示出来