-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploying to gh-pages from @ 4139e6e 🚀
- Loading branch information
1 parent
2e6484c
commit 2376d89
Showing
21 changed files
with
635 additions
and
1,098 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
[ | ||
{ | ||
"id": "26b6ebca-58e6-4814-86ea-494ed844c9a8", | ||
"skip": false, | ||
"title": "Parsing", | ||
"background": "JSON Path is a syntax for querying JSON data.\n\n_JsonPath.Net_ provides an implementation that conforms to the official IETF\nspecification, [RFC 9535](https://www.rfc-editor.org/rfc/rfc9535.html). Like the other\nguides on this site, this guide will teach you how to use the library _JsonPath.Net_.\n\nHowever, because there are so few implementations of the RFC, and little to no\ndocumentation of it, this guide will also teach you the features of JSON Path itself,\nas described by the RFC.\n\nWe'll start with the library since there is less to cover, then we'll move on to\nwhat you can do with it.\n\nUnlike JSON Schema, JSON Logic, or other technologies that are actually represented in\nJSON, JSON Path is its own syntax, so it must usually be parsed. The primary way to\nparse a path is using the static `JsonPath.Parse()` method.\n", | ||
"docs": "path/basics", | ||
"api": null, | ||
"schemaDocs": null, | ||
"instructions": "Parse the given JSON Path text into a `path` variable.\n", | ||
"contextCode": "using System.Text.Json;\nusing System.Text.Json.Nodes;\nusing Json.Path;\n\nnamespace LearnJsonEverything;\n\npublic class Lesson : ILessonRunner<PathResult>\n{\n public PathResult Run(JsonObject test)\n {\n var data = test[\"data\"];\n var pathText = \"$.foo.bar\";\n\n /* USER CODE */\n\n return path.Evaluate(data);\n }\n}", | ||
"tests": [ | ||
{ | ||
"data": { | ||
"foo": { | ||
"bar": "a string" | ||
} | ||
}, | ||
"result": [ | ||
"a string" | ||
] | ||
} | ||
], | ||
"solution": "using System.Text.Json;\nusing System.Text.Json.Nodes;\nusing Json.Path;\n\nnamespace LearnJsonEverything;\n\npublic class Lesson : ILessonRunner<PathResult>\n{\n public PathResult Run(JsonObject test)\n {\n var data = test[\"data\"];\n var pathText = \"$.foo.bar\";\n\n var path = JsonPath.Parse(pathText);\n\n return path.Evaluate(data);\n }\n}" | ||
}, | ||
{ | ||
"id": "bee48c06-4b02-4e2a-9dd7-97eb1c25e7d1", | ||
"skip": false, | ||
"title": "Parsing Safely", | ||
"background": "Unlike JSON Schema, JSON Logic, or other technologies that are actually represented in\r\nJSON, JSON Path is its own syntax, so it must usually be parsed. The primary way to\r\nparse a path is using the static `JsonPath.Parse()` method, but this can throw exceptions when the path string is not valid.\r\n\r\nIf you want to avoid an exception, `JsonPath.TryParse()` exists to parse a path string in a way that does not throw an exception.", | ||
"docs": "path/basics/#path-in-code", | ||
"api": null, | ||
"schemaDocs": null, | ||
"instructions": "Change the code to safely parse the text. Return null if parsing fails.", | ||
"contextCode": "using System.Text.Json;\r\nusing System.Text.Json.Nodes;\r\nusing Json.Path;\r\n\r\nnamespace LearnJsonEverything;\r\n\r\npublic class Lesson : ILessonRunner<PathResult>\r\n{\r\n public PathResult Run(JsonObject test)\r\n {\r\n var data = test[\"data\"];\r\n var pathText = test[\"pathText\"].GetValue<string>();\r\n\r\n var path = JsonPath.Parse(pathText);\r\n\r\n return path.Evaluate(data);\r\n }\r\n}", | ||
"tests": [ | ||
{ | ||
"data": { | ||
"foo": { | ||
"bar": "a string" | ||
} | ||
}, | ||
"pathText": "$['foo'].bar", | ||
"result": [ | ||
"a string" | ||
] | ||
}, | ||
{ | ||
"data": { | ||
"foo": { | ||
"bar": "a string" | ||
} | ||
}, | ||
"pathText": "$.['foo'].bar", | ||
"result": null | ||
} | ||
], | ||
"solution": "using System.Text.Json;\r\nusing System.Text.Json.Nodes;\r\nusing Json.Path;\r\n\r\nnamespace LearnJsonEverything;\r\n\r\npublic class Lesson : ILessonRunner<PathResult>\r\n{\r\n public PathResult Run(JsonObject test)\r\n {\r\n var data = test[\"data\"];\r\n var pathText = test[\"pathText\"].GetValue<string>();\r\n\r\n if (!JsonPath.TryParse(pathText, out var path))\r\n {\r\n return null;\r\n }\r\n\r\n return path.Evaluate(data);\r\n }\r\n}" | ||
} | ||
] |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.