Javascript jquery 等效于 JSON.stringify

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11118947/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 04:33:17  来源:igfitidea点击:

jquery equivalent for JSON.stringify

javascriptjqueryjson

提问by Highmastdon

Possible Duplicate:
Serializing to JSON in jQuery

可能的重复:
在 jQuery 中序列化为 JSON

I'm using jquery as a library in my javascript code. But sometimes I have to JSON.stringify().

我在我的 javascript 代码中使用 jquery 作为库。但有时我不得不这样做JSON.stringify()

When I want to keep my code IE compatible I use
$("head").append('<script type="text/javascript" src="../Includes/json2.js"></script>');
to get my JSON.stringify()to work. Isn't there a equivalent in jqueryfor JSON.stringify()?

当我想保持我的代码与 IE 兼容时,我
$("head").append('<script type="text/javascript" src="../Includes/json2.js"></script>');
用来让我JSON.stringify()的工作。没有等价的jqueryforJSON.stringify()吗?

回答by Mariusz Jamro

There is no such functionality in jQuery. Use JSON.stringifyor alternatively any jQuery plugin with similar functionality (e.g jquery-json).

jQuery 中没有这样的功能。使用JSON.stringify或替代任何具有类似功能的 jQuery 插件(例如jquery-json)。