P
P
prog3232014-04-14 12:08:58
JSON
prog323, 2014-04-14 12:08:58

How to properly make json in c#?

now I'm making json code

var v = new
            {
                token = token, 
                method = "abc", 
                param = new string[1] { "data: [nokia]"},
                locale = "ru"
            };

            json = jss.Serialize( v );

get
{"token":"test","method":"abc","param":["data: [nokia]"],"locale":"ru"}

and you need to get json with "param": {"data": ["nokia"]}
{
"locale": "ru",
"token": "test",
"method": "abc", 
"param": {"data": ["nokia"]}
}

"param": {"data": ["nokia"]} is not formed correctly,
what should be corrected in the code?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis Morozov, 2014-04-14
@morozovdenis

var v = new
{
    token = token, 
    method = "abc", 
    param = new Dictionary< String, List<String> >() { { "data", new List<String>() { "nokia" } } },
    locale = "ru"
};

json = jss.Serialize( v );

P
prog323, 2014-04-14
@prog323

on the

(
                        "data", 
                        new List<String>() { "nokia" } 
                    )

writes
None of the overloads of the "Add" method takes "1" arguments

S
Smerig, 2014-04-19
@Smerig

Param = new { data = new[] {"Nokia"}}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question