LINQ to JSON has methods available for parsing JSON from a string or loading JSON directly from a file.
JSON values can be read from a string using Argon.JToken.Parse(System.String)
.
var json = """
{
CPU: 'Intel',
Drives: [
'DVD read/writer',
'500 gigabyte hard drive'
]
}
""";
var o = JObject.Parse(json);
var json = """
[
'Small',
'Medium',
'Large'
]
""";
var a = JArray.Parse(json);
JSON can also be loaded directly from a file using Argon.JToken.ReadFrom(Argon.JsonReader)
.
using var reader = File.OpenText(@"c:\person.json");
var o = (JObject) JToken.ReadFrom(new JsonTextReader(reader));
// do stuff
- LINQtoJSON
Argon.JToken.Parse(System.String)
Argon.JToken.ReadFrom(Argon.JsonReader)