解决IE8 内置JSON.stringify,中文变unicode的问题

今天做项目中出现在IE下出现把json对象转为json串中文变成unicode的问题,最后经过排查,发现是IE8内置JSON.stringify()引起的,解决方法如下:

// 把json对象转为json串

var policy_content = JSON.stringify(data.jsonObject);

policy_content={policy":[{"name":"must_installed","enabled":1,"key_check":1,"content":{"must_installed_list":["\u641c\u72d7"]},"desc":"\u5fc5\u987b\u5b89\u88c5\u8f6f\u4ef6"}]}

// 利用JS再做了一层解析,把unicode又变成中文。

eval(" var g_policy = '"+policy_content+"';");

g_policy=={policy":[{"name":"must_installed","enabled":1,"key_check":1,"content":{"must_installed_list":["搜狗"]},"desc":"必须安装软件"}]}



你可能感兴趣的:(解决IE8 内置JSON.stringify,中文变unicode的问题)