2

I want to end up with a JSON object like this:

{ "somefield" : ["a", "b", "c"] }

I tried

string json = new JavaScriptSerializer().Serialize(new
                        { 
                            somefield  = ["a", "b", "c"]
                        });

but I get a syntax error (Syntax Error, ',' expected)

1 Answer 1

2

Just use new keyword

string json = new JavaScriptSerializer().Serialize(new
              {
                  somefield = new[] { "a", "b", "c" }
              });

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.