3

Using JSON.Stringify I pass the following string inside another Stringify object.

[
    [
        "I-000-4310-000",
        "Convention Registration",
        "59.99"
    ],
    [
        "I-000-4311-000",
        "Convention Breakout",
        "39.99"
    ]
]

In my C# web service I need to split the string apart into a string array that looks like this:

 string[, ,] GLCodes = new string[,,] 
 { 
    {
        { "I-000-4310-000", "Convention Registration", "59.99" }, 
        { "I-000-4311-000", "Convention Breakout", "9.99" }
    } 
 };

What is the simplest way to do this?

Hamlet Hakobyan
  • 32,965
  • 6
  • 52
  • 68
Connie DeCinko
  • 996
  • 5
  • 19
  • 39
  • Connie take a look at this site and see if it helps http://stackoverflow.com/questions/9586585/convert-json-to-a-c-sharp-array – MethodMan Feb 09 '13 at 23:27
  • do you use JSON `JavaScriptSerializer` look here for an example [JavaScriptSerializer](http://atsung.wordpress.com/2008/08/07/javascriptserializer-example/) – MethodMan Feb 09 '13 at 23:30
  • 1
    I recommend [Json.NET](http://james.newtonking.com/pages/json-net.aspx). Read up about it (or the alternatives), then get back when there is a problem with some *actual* code :D As of right now, this is "not a real question" (or, not more of a question than that which can be succinctly answered in a comment without writing the code for you). –  Feb 09 '13 at 23:33

1 Answers1

7

Using Json.NET you can deserialize that list with this

string[][] strings = JsonConvert.DeserializeObject<string[][]>(jsonData);

Hope this helps!

Connie Hilarides
  • 1,685
  • 15
  • 13