Skip to content

Latest commit

 

History

History
26 lines (18 loc) · 677 Bytes

ToObjectType.md

File metadata and controls

26 lines (18 loc) · 677 Bytes

Convert JSON to a Type

This sample converts LINQ to JSON objects to .NET types using Argon.JToken.ToObject(System.Type).

var v1 = new JValue(true);

var b = (bool) v1.ToObject(typeof(bool));

Console.WriteLine(b);
// true

var i = (int) v1.ToObject(typeof(int));

Console.WriteLine(i);
// 1

var s = (string) v1.ToObject(typeof(string));

Console.WriteLine(s);
// "True"

snippet source | anchor