Take the 2-minute tour ×

I need to pass back a JSON result for a routine I am working with. How can I encode an Array I created to JSON? I am writing this in VB.net

share|improve this question
add comment

4 Answers

up vote 16 down vote accepted
Dim serializer as New JavaScriptSerializer()
Dim arrayJson as String = serializer.Serialize(myArray)
share|improve this answer
using System.Web.Script.Serialization; –  Sameer Alibhai Dec 7 '11 at 16:09
add comment

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.

share|improve this answer
I've used Json.NET with much success, it's quite nice. –  Matt Olenik Feb 23 '09 at 19:54
The code that bdukes post did the trick. I will look into your 4 suggestions as well though. Thanks! –  pixeldev Feb 23 '09 at 20:59
bdukes is the one I actually recommend. It's item #3 in the list. –  Brig Lamoreaux Feb 24 '09 at 1:05
All are valid, with more or less hurdles, but I would go with option #2 (Json.NET) –  Orry Mar 29 '12 at 16:14
add comment

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.

share|improve this answer
add comment

you could try the javascript serializer (http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx) I believe it was deprecated for a while by Microsoft but then un-deprecated (is that a word??) when they wanted to use it in MVC

share|improve this answer
add comment

Your Answer


