C#C
C#3y ago
jgomezal

✅ [RESOLVED] Newtonsoft :: wrong serialization format

Dear all,

I'm requesting your help, because I don't understand what I'm doing wrong.

 string operations = "{\"inumoper\": \"44444\", \"itdoper\": \"ORD1\"}";

Dictionary<string, string> objParams = new Dictionary<string, string>
{
    {"accion", "LOAD" },
    {"operaciones", operations},
};

string[] arrParams = new string[4];
arrParams[0] = JsonConvert.SerializeObject(objParams, Formatting.None);
arrParams[1] = "123456789";
arrParams[2] = "1001";
arrParams[3] = "0";

Dictionary<string, Array> objSend = new Dictionary<string, Array>
{
    {"_parameters", arrParams }
};          
`

I need this data with this format:
"{\"_parameters\":[{\"accion\":\"LOAD\",\"operaciones\":[{\"inumoper\":\"44444\",\"itdoper\":\"ORD1\"}]},\"123456789\",\"1001\",\"0\"]}"


But I'm getting it like this:
"{\"_parameters\":["{\"accion\":\"LOAD\",\"operaciones\":\"{\\\"inumoper\\\": \\\"44444\\\", \\\"itdoper\\\": \\\"ORD1\\\"}\"}"]},\"123456789\",\"1001\",\"0\"]}"
`

As you see, in the "operaciones" array, I'm receiving an escape for a backslash and I don't need it. Do you know how can I solve it?

Thanks in advance,
Migue
Was this page helpful?