Browse Source

解决JSON格式化时候的encode问题

zxlie 7 years ago
parent
commit
caab4b1785
4 changed files with 8 additions and 2 deletions
  1. 3 0
      apps/json-format/automatic.js
  2. 1 1
      apps/json-format/index.html
  3. 3 0
      apps/json-format/index.js
  4. 1 1
      apps/manifest.json

+ 3 - 0
apps/json-format/automatic.js

@@ -97,6 +97,9 @@ module.exports = (() => {
      * @param {Object} text
      */
     let _uniDecode = function (text) {
+        try{
+            text = decodeURIComponent(text);
+        }catch(e){}
         text = text.replace(/(\\)?\\u/gi, "%u").replace('%u0025', '%25');
 
         text = unescape(text.toString().replace(/%2B/g, "+"));

+ 1 - 1
apps/json-format/index.html

@@ -15,7 +15,7 @@
                         <a href="http://www.baidufe.com/fehelper/feedback.html" target="_blank" class="x-a-high">
                             <img src="../static/img/fe-16.png" alt="fehelper"/> FeHelper</a>:JSON格式化查看
                         <span class="x-xdemo" ref="demoLink1" @click="setDemo">示例1:JSON片段</span>
-                        <a class="x-xdemo" href="https://www.sojson.com/open/api/weather/json.shtml?city=%E5%8C%97%E4%BA%AC" target="_blank">示例2:在线JSON-1</a>
+                        <a class="x-xdemo" href="http://baike.baidu.com/api/openapi/BaikeLemmaCardApi?scope=103&format=json&appid=379020&bk_key=%E9%93%B6%E9%AD%82&bk_length=600" target="_blank">示例2:在线JSON-1</a>
 
                         <span id="layoutBar">
                             <button id="btnLeftRight" ref="btnLeftRight" class="selected" @click="changeLayout('left-right')">左右布局</button><button id="btnUpDown" ref="btnUpDown" @click="changeLayout('up-down')">上下布局</button>

+ 3 - 0
apps/json-format/index.js

@@ -236,6 +236,9 @@ new Vue({
          * @param {Object} text
          */
         _uniDecode : function (text) {
+            try{
+                text = decodeURIComponent(text);
+            }catch(e){}
             text = text.replace(/(\\)?\\u/gi, "%u").replace('%u0025', '%25');
 
             text = unescape(text.toString().replace(/%2B/g, "+"));

+ 1 - 1
apps/manifest.json

@@ -1,6 +1,6 @@
 {
   "name": "WEB前端助手(FeHelper)",
-  "version": "2018.10.2115",
+  "version": "2018.10.2214",
   "manifest_version": 2,
   "default_locale": "zh_CN",
   "description": "FE助手:包括JSON格式化、二维码生成与解码、信息编解码、代码压缩、美化、页面取色、Markdown与HTML互转、网页滚动截屏、正则表达式、时间转换工具、编码规范检测、页面性能检测、Ajax接口调试、密码生成器、JSON比对工具",