asp.net mvc - C#: Json validation from user input -


i need validate json file server side, im using asp.net mvc c#, have method in controller

public actionresult validate(httppostedfilebase jsonfile)      {         bool validjson = false;         var serializer = new javascriptserializer();          try          {             var result = serializer.deserialize<dictionary<string, object>>(how should pass json file here ??);             validjson = true;         }          catch(exception ex)         {             validjson = false;         }      } 

this best way validate ? ... sorry don't know how pass json string parameter, have tried jsonfile.inputstream.tostring(), jsonfile.tostring() ... needs ?, json user's route ? ... in advance

well how this:

using (var reader = new streamreader(jsonfile.inputstream)) {     string jsondata = reader.readtoend();     var serializer = new javascriptserializer();      var result = serializer.deserialize<dictionary<string, object>>(jsondata);     // dragons here ... } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -