js判斷是不是Json對象

有兩種方法javascript 1.使用正則表達式(推薦),代碼以下:java if (/^[\],:{}\s]*$/.test(text.replace(/\\["\\\/bfnrtu]/g, '@'). replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']'). replace(/(?:^|
相關文章
相關標籤/搜索