JSON serialization/deserialization in ASP.Net Core

后端 未结 2 1170
不思量自难忘°
不思量自难忘° 2020-12-01 03:25

Since there is no JavaScriptSerializer, what native implementation can be used to handle this?

I noticed JsonResult and I can format data t

2条回答
  •  执念已碎
    2020-12-01 03:57

    .net core

    using System.Text.Json;

    To serialize

    var jsonStr = JsonSerializer.Serialize(MyObject)
    

    Deserialize

    var weatherForecast = JsonSerializer.Deserialize(jsonStr);
    

    For more information about excluding properties and nulls check out This Microsoft side

提交回复
热议问题