json json string transfer objects (rpm)

Where the source is forgotten, and today requires, before suddenly thought of a perfect piece of code to solve, as a memo posted

        //将json字符串转为json对象
        var jsonStr = data.data
              //去掉字符串中的空格
              jsonStr = jsonStr.replace(" ","");
             //typeof https://www.cnblogs.com/liu-fei-fei/p/7715870.html
             if(typeof jsonStr!='object'){
             //去掉饭斜杠
             jsonStr = jsonStr.replace(/\ufeff/g,"")
                          var jsonObj = JSON.parse(jsonStr)
                          that.booklist = jsonObj
             }
Published 65 original articles · won praise 58 · Views 100,000 +

Guess you like

Origin blog.csdn.net/AngelLover2017/article/details/82951768