Sorry, the diff of this file is not supported yet
+60
| # JsonPath | ||
| A .NET library for extracting values from JSON and XML with simple expressions, similar to XPath for XML but type-safe. | ||
| ## Features | ||
| - **Simple JSON Navigation**: Extract values with intuitive syntax like `json[2]["aNumber"]` | ||
| - **Type-Safe Operations**: Built-in type conversions with `.AsInt`, `.AsString`, `.AsDictionary`, etc. | ||
| - **LINQ Integration**: Full support for LINQ queries on JSON data | ||
| - **XML Support**: Parse and navigate XML documents with the same syntax | ||
| - **No Exceptions**: Invalid paths return default values instead of throwing exceptions | ||
| - **Enumerable Support**: Iterate over JSON arrays and objects with foreach loops | ||
| ## Quick Start | ||
| ```csharp | ||
| using JsonPath; | ||
| // Parse JSON | ||
| var json = Node.FromJson("[ \"1st\", \"2nd\", { \"aString\": \"Hello World\", \"aNumber\": 42 } ]"); | ||
| // Extract values | ||
| int number = json[2]["aNumber"]; // 42 | ||
| string text = json[2]["aString"]; // "Hello World" | ||
| var explicitInt = json[2]["aNumber"].AsInt; // 42 | ||
| // Safe navigation - no exceptions for invalid paths | ||
| int invalid = json[1000]["noNumber"]; // 0 (default value) | ||
| // Iterate over collections | ||
| foreach (var pair in json[2]) { | ||
| Console.WriteLine($"{pair.Key} = {pair.Value}"); | ||
| } | ||
| // LINQ support | ||
| int result = json[2].Where(x => x.Key == "aNumber").Select(x => x.Value).First(); | ||
| ``` | ||
| ## XML Support | ||
| ```csharp | ||
| var xml = Node.FromXml("<root><item>1st</item><item>2nd</item><item><aNumber>42</aNumber></item></root>"); | ||
| var number = xml[Xml.Children][2][Xml.Children] | ||
| .AsList.FirstOrDefault(x => x[Xml.Name] == "aNumber")?[Xml.Text].AsInt; | ||
| ``` | ||
| ## Installation | ||
| ``` | ||
| dotnet add package JsonPath | ||
| ``` | ||
| ## Requirements | ||
| - .NET 8.0 or later | ||
| - Newtonsoft.Json | ||
| ## License | ||
| MIT License |
Sorry, the diff of this file is not supported yet
@@ -1,1 +0,8 @@ | ||
| <?xml version="1.0" encoding="utf-8"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" /><Default Extension="nuspec" ContentType="application/octet" /><Default Extension="dll" ContentType="application/octet" /><Default Extension="psmdcp" ContentType="application/vnd.openxmlformats-package.core-properties+xml" /></Types> | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"> | ||
| <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" /> | ||
| <Default Extension="psmdcp" ContentType="application/vnd.openxmlformats-package.core-properties+xml" /> | ||
| <Default Extension="dll" ContentType="application/octet" /> | ||
| <Default Extension="md" ContentType="application/octet" /> | ||
| <Default Extension="nuspec" ContentType="application/octet" /> | ||
| </Types> |
+13
-12
@@ -1,19 +0,20 @@ | ||
| <?xml version="1.0"?> | ||
| <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd"> | ||
| <metadata> | ||
| <id>JsonPath</id> | ||
| <version>1.0.1</version> | ||
| <title>JsonPath</title> | ||
| <authors>Heiner Wolf</authors> | ||
| <owners>Heiner Wolf</owners> | ||
| <version>1.0.0</version> | ||
| <authors>wolfspelz</authors> | ||
| <license type="expression">MIT</license> | ||
| <licenseUrl>https://licenses.nuget.org/MIT</licenseUrl> | ||
| <readme>README.md</readme> | ||
| <projectUrl>https://github.com/wolfspelz/JsonPath</projectUrl> | ||
| <requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
| <description>JsonPath Class Library: Inspect values in JSON strings with single line expressions and plain old CLR objects without using foreach/if to extract values from JSON. Extract the 42 from ["first",{"aString":"HelloWorld","aNumber":42}] with C# expression: json.List[1].Dictionary["aNumber"].Int</description> | ||
| <releaseNotes>New</releaseNotes> | ||
| <copyright>Copyright 2016</copyright> | ||
| <tags>JSON,Parser,JsonPath,XPath,POCO</tags> | ||
| <description>A .NET library for extracting values from JSON with simple expressions, similar to XPath for XML but type-safe. Supports JSON and XML parsing with intuitive syntax like json[2]["aNumber"] and LINQ integration.</description> | ||
| <tags>json xml path query parser xpath linq</tags> | ||
| <repository type="git" url="https://github.com/wolfspelz/JsonPath" commit="870054a274de6798f11063c4cf4ab1b575bfd091" /> | ||
| <dependencies> | ||
| <dependency id="Newtonsoft.Json" version="9.0.1" /> | ||
| <group targetFramework="net8.0"> | ||
| <dependency id="Newtonsoft.Json" version="13.0.3" exclude="Build,Analyzers" /> | ||
| </group> | ||
| </dependencies> | ||
| </metadata> | ||
| </package> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet