0

Im really new to this, I need to generate a Json File from a class in c#, im able to serialize the class using

 var json = new JavaScriptSerializer().Serialize(jsonfile);

anyway the output is somethin like this :

{"empleado":"","nombre":"Name Here III"}

And with this im receiveing a bad request error

but on the sample file that the customer sent to me they have something like this:

{""empleado"":"""",""nombre"" :""Prueba6""}

And it works!!

note that they have a double qoutes twice, and the serializer is generating double quote only once. what I'm doing wrong?

AFF
  • 117
  • 10
  • We have no idea what you're *doing* with the JSON. Please provide a [mcve] with more context. – Jon Skeet Feb 02 '17 at 18:52
  • can you show us the value of jsonfile please – Simon Price Feb 02 '17 at 18:52
  • The JSON that JavaScriptSerializer outputs in your case is completely correct and you won't get it to output the second variant since that isn't correct JSON. If the customer expects there to be twice as many quotes then they don't want real JSON. – Karl-Johan Sjögren Feb 02 '17 at 18:58
  • 1
    take a look at this post here and use NewtonSoft JSON.Net http://stackoverflow.com/questions/16294963/json-net-serialize-object-with-root-name – Simon Price Feb 02 '17 at 18:59
  • MY BAD!!!! I scaped the text in visual studio that is the reason i visualize double qoutes twice!!! Im so sorry, How Can I delete this stupid question? – AFF Feb 02 '17 at 19:00

0 Answers0