SerializeExtendReadJsonT(String, NullableJsonOption) Method
讀取Json字串反序列化為物件
Namespace: eBizprise.FrameworkAssembly: eBizprise.Framework.SerializeHelper (in eBizprise.Framework.SerializeHelper.dll) Version: 25.0.0.0+adf38c4ccb2bf98d8ad258a6278302b5e05a94ed
public static T ReadJson<T>(
this string jsonString,
JsonOption? jsonOption
)
- jsonString String
- JSON字串
- jsonOption NullableJsonOption
- Json選項
- T
- 物件類型
TTIn Visual Basic and C#, you can call this method as an instance method on any object of type
String. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
讀取字串內容轉換為指定類型的物件
string jsonString = "{ StringColumn: \"StringData\", IntColumn: 0, DecimalColumn: 1.3 }";
TestClass testClass = jsonString.ReadJson<TestClass>(JsonOption.IncludeNull);
///
/// 測試類別
///
class TestClass
{
///
/// 文字欄位
///
public string StringColumn { get; set; }
///
/// 整數欄位
///
public int IntColumn { get; set; }
///
/// 數字欄位
///
public decimal DecimalColumn { get; set; }
///
/// 二進位欄位
///
public byte[] ByteColumn { get; set; }
}
| Date | Version | Description |
|---|
| 2020/02/07 | 1.0.0.0 | 初版 |
| 2020/05/22 | 1.0.3.0 | 調整序列化預設Formatting為None |
| 2025/09/19 | 25.0.0.0 | 彙整2025年度初版 |