Skip to content

SwingCosmic/LoveKicher.DynamicJson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Deserialize JSON to dynamic object

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages