简体   繁体   中英

How can I JSON encode an array in VB.NET?

I need to pass back a JSON result for a routine I am working with. In VB.NET , how can arrays be JSON encoded?

Dim serializer as New JavaScriptSerializer()
Dim arrayJson as String = serializer.Serialize(myArray)

There are four ways:

  1. Roll your own with a Custom formatter
  2. Json.NET .
  3. JavaScriptSerializer
  4. DataContractJsonSerializer

I recently blogged about how to do Json Serialization .

You are going to want to look into JSON serialization. Here is a good article that explains one way to do it (unfortunately the examples are in C#) but with more information we can probalby steer you towards the right toolkit.

您可以尝试使用javascript序列化器( http://msdn.microsoft.com/zh-cn/library/system.web.script.serialization.javascriptserializer.aspx ),我相信它已经被Microsoft淘汰了一段时间,但随后不推荐使用(是一个词吗?),当他们想在MVC中使用它时

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM