Read JSON from a file using JObject

April 6, 2024 ยท View on GitHub

This sample reads JSON from a file into a Argon.JObject.

var o1 = JObject.Parse(File.ReadAllText(@"c:\videogames.json"));

// read JSON directly from a file
using var file = File.OpenText(@"c:\videogames.json");
using var reader = new JsonTextReader(file);
var o2 = (JObject) JToken.ReadFrom(reader);

snippet source | anchor