I ve a JS array, comprising multiple JS objects. I want to convert JS array to JSON type, & pass that to controller (using AJAX - POST call). So that I can retrieve the values from the Array of Objects, in my controller & save them in DB.
我有一个JS数组,包含多个JS对象。我想将JS数组转换为JSON类型,并将其传递给控制器(使用AJAX - POST调用)。这样我就可以在控制器中从对象数组中检索值并将它们保存在DB中。
NB: I ve tried using $.stringify(myArry)
, but its not able to send data to controller in JSON format. Also I cant use $.toJSON(myArray)
, as I m not allowed to include a new plugin in our solution. :(
注意:我尝试使用$ .stringify(myArry),但它无法以JSON格式向控制器发送数据。另外我不能使用$ .toJSON(myArray),因为我不允许在我们的解决方案中包含新插件。 :(
Plz suggest me any other idea.
Plz建议我任何其他想法。
Else if anyone can let me know how to deserelize the array in cotroller, that I ve sent by using $.stringify(myArry), that would also great. Something like
否则,如果有人可以让我知道如何在cotroller中使用$ .stringify(myArry)发送数组,那也很棒。就像是
var result = JavaScriptConvert.DeserializeObject(inputContent, JsonDataType);
1 个解决方案
#1
1
Per this post, it looks like you'll have to add another plug-in:
根据这篇文章,看起来你必须添加另一个插件:
JSON stringify missing from jQuery 1.4.1?
JSON 1.4.1中缺少JSON stringify?
The Google solution looks good: http://code.google.com/p/jquery-json/
Google解决方案看起来不错:http://code.google.com/p/jquery-json/
Or just use the JSON object from Crockford: https://github.com/douglascrockford/JSON-js
或者只使用Crockford的JSON对象:https://github.com/douglascrockford/JSON-js
#1
1
Per this post, it looks like you'll have to add another plug-in:
根据这篇文章,看起来你必须添加另一个插件:
JSON stringify missing from jQuery 1.4.1?
JSON 1.4.1中缺少JSON stringify?
The Google solution looks good: http://code.google.com/p/jquery-json/
Google解决方案看起来不错:http://code.google.com/p/jquery-json/
Or just use the JSON object from Crockford: https://github.com/douglascrockford/JSON-js
或者只使用Crockford的JSON对象:https://github.com/douglascrockford/JSON-js