最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - How can I serialize an object in Javascript, then deserialize it in asp.net? - Stack Overflow

programmeradmin0浏览0评论

I have a custom Javascript object that has a few string and float members. I'd like to serialize an array of them in Javascript, assign the result to a hidden field, and then retrieve and deserialize them in the codebehind for my asp application.

Is there a standard way to do this?

I have a custom Javascript object that has a few string and float members. I'd like to serialize an array of them in Javascript, assign the result to a hidden field, and then retrieve and deserialize them in the codebehind for my asp application.

Is there a standard way to do this?

Share Improve this question edited Oct 1, 2010 at 9:14 NibblyPig asked Oct 1, 2010 at 8:46 NibblyPigNibblyPig 53k75 gold badges218 silver badges380 bronze badges 1
  • I clarified my question because it wasn't clear before that I want to serialize to JSON in javascript – NibblyPig Commented Oct 1, 2010 at 9:14
Add a ment  | 

3 Answers 3

Reset to default 3

You can Use JSON.

With JSON you serialize data and serialize it in Different language.

http://flexjson.sourceforge/

http://forums.c-sharpcorner./Blogs/BlogDetail.aspx?BlogId=2028

http://www.nateirwin/2008/11/20/json-array-to-c-using-jsonnet/

http://msdn.microsoft./en-us/library/bb299886.aspx

http://www.codeproject./Tips/79435/Deserialize-JSON-with-Csharp.aspx

what you need is JSON.

both javascript and C# can handle it.

article: http://www.nateirwin/2008/11/20/json-array-to-c-using-jsonnet/

also: http://www.json/ (scroll to the end)

Check this answer How do I serialize a C# anonymous type to a JSON string?

Edit:
Since JavaScriptSerializer is deprecated .. you can use DataContractJsonSerializer. MSDN: DataContractJsonSerializer Blog post on how to use it: http://pietschsoft./post/2008/02/NET-35-JSON-Serialization-using-the-DataContractJsonSerializer.aspx

发布评论

评论列表(0)

  1. 暂无评论