C #. Net core: How to use Jsonconvert replace JavaScriptSerializer

There are no system. Runtime. Serialization. JSON and system. Web. Script. Serialization in. Net core, so there is no JavaScript serializer. Therefore, jsonconvert in newtonsoft. JSON can be used to replace jsonconvert when porting projects


//.net framework
//JavaScriptSerializer serializer = new JavaScriptSerializer();
//var res = serializer.Serialize(YourObject);

//.net core Newtonsoft.Json
var res = JsonConvert.SerializeObject(YourObject);

Similar Posts: