Need Help using

Jun 30, 2008 at 9:53 PM

I am new to and I have a couple questions.

I been just playing around it for a couple minutes and I did this:

    object[] test = new object[2];
        test[0] = "2";
        test[1] = "3";

       string mytest = JavaScriptConvert.SerializeObject(test);

My result was:


I thought that json used the curly braces so it would look like {"2","3"}

My second question is do I always have to make a object array or a class?

Like I am going to have up to 218 peices of data to send at a given time and the format would look like this:

Images/Hiragana/a-o/a.gif, a

So I could have 218 of these at a given time so I don't think doing something like this would be practical:

{ImagePath:  "Images/Hiragana/a-o/a.gif", answer: "a", ImagePath2: "Images/Hiragana/a-o/a.gif", answer2: "a"}

So having a name for each one does not seem viable. So I don't think making a class would help me(or not at least based on the example that was given)

Product product = new Product();
product.Name = "Apple";
product.Expiry = new DateTime(2008, 12, 28);
product.Price = 3.99M;
product.Sizes = new string[] { "Small", "Medium", "Large" };
string output = JavaScriptConvert.SerializeObject(product);
//  "Name": "Apple",
//  "Expiry": "\/Date(1230375600000+1300)\/",
//  "Price": 3.99,
//  "Sizes": [
//    "Small",
//    "Medium",
//    "Large"
//  ]
Product deserializedProduct = (Product)JavaScriptConvert.DeserializeObject(output, typeof(Product));

So I think the best would be something like


So how do I do this with if you know a better way to format it how would I do that?)