c# - Convert an IFile (JSON File) to MyObject -




i upload json file html form explained here in first paragraph. accept 1 file @ time controller:

public iactionresult upload(iformfile file) { } 

now want convert file containing json object. this accepted answer of cuong le. how convert file lets myobject? how deserialize file? (newtonsoft lib import right?)

you can read text file , convert json. can try like,

string filecontent = null;        using (var reader = new streamreader(file.openreadstream()))        {          filecontent = reader.readtoend();        }    var result = jsonconvert.deserializeobject<myobject>(filecontent ); 

yes, can use newtonsoft nuget package deserializing.





wiki

Comments

Popular posts from this blog

firebase - How to wait value in Ionic 2 -

Jenkins: find build number for git commit -

ROS vtk and kubuntu problems -