Skip to content

Latest commit

 

History

History
37 lines (29 loc) · 873 Bytes

README.md

File metadata and controls

37 lines (29 loc) · 873 Bytes

DynamicJson

Deserialize JSON to JavaScript-like dynamic object.

Nuget Release

Requirement

  • System.Text.Json

Quick Start

using System.Text.Json;
using LoveKicher.DynamicJson;

var json =
@"{
    'numberValue': 9876547210.33,
    'boolValue': false,
    'array': [
        null, 
        'someText', 
        {
            'nested.prop': 'nested value'
        }
    ]
}".Replace("'", "\"");

dynamic value = JsonSerializer
    .Deserialize<JsonElement>(json)
    .DeserializeDynamic();

Console.WriteLine(value.boolValue); // false
Console.WriteLine(value.array[2]["nested.prop"]); // nested value

Console.WriteLine(((object)value).GetType().FullName); // LoveKicher.DynamicJson.DynamicDictionary