Skip to content

Commit

Permalink
Deploying to gh-pages from @ 92c2143 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
gregsdennis committed Jun 8, 2024
1 parent 925f8b9 commit edad082
Show file tree
Hide file tree
Showing 15 changed files with 182 additions and 39 deletions.
Binary file modified _framework/LearnJsonEverything.Template.dll
Binary file not shown.
Binary file modified _framework/LearnJsonEverything.Template.dll.br
Binary file not shown.
Binary file modified _framework/LearnJsonEverything.Template.dll.gz
Binary file not shown.
Binary file modified _framework/LearnJsonEverything.Template.pdb.gz
Binary file not shown.
Binary file modified _framework/LearnJsonEverything.dll
Binary file not shown.
Binary file modified _framework/LearnJsonEverything.dll.br
Binary file not shown.
Binary file modified _framework/LearnJsonEverything.dll.gz
Binary file not shown.
Binary file modified _framework/LearnJsonEverything.pdb.gz
Binary file not shown.
6 changes: 3 additions & 3 deletions _framework/blazor.boot.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"mainAssemblyName": "LearnJsonEverything",
"resources": {
"hash": "sha256-/mfCyRbUz0PTj+9KQsEFe06GWi15knYDk0T/2h0FB+4=",
"hash": "sha256-we72luh3SW/LOe3cXuF/tn/b2V24P9/Z9Kd5nwZnJqs=",
"jsModuleNative": {
"dotnet.native.8.0.6.suuomc2hr0.js": "sha256-YU6M9+jtDVnB8/wtrgIndOstzNh778Ls8g9XnbjorSk="
},
Expand All @@ -24,8 +24,8 @@
"Json.More.dll": "sha256-xr0aE0+HsrvtjruJdaapKt2/DGB0qSUz+xD0XmvawxM=",
"JsonPointer.Net.dll": "sha256-DzV9BEIGNC1mcOpb+JYI2gGXuDG5qg157LjFTnJ6pAE=",
"JsonSchema.Net.dll": "sha256-iCLcArFhOdHD16SQ2km8JXYsJmbv4fa37t+iopIb8+w=",
"LearnJsonEverything.dll": "sha256-HMhC+Eb7AO6iyR3thMWDV60cIw9GaIXEmt5K87t1CUQ=",
"LearnJsonEverything.Template.dll": "sha256-NqX+HByG0vRSrwzta/CYol2kSbSCsGKVammRUbswD24=",
"LearnJsonEverything.dll": "sha256-aczvZo8vmBSgeUl7MHBCHcnm3m0OoDx8OovLP0yzCNA=",
"LearnJsonEverything.Template.dll": "sha256-aHRf87hKDnj5TSiRZDRGWixD5dGPi6qCQ+aHxTy56dM=",
"Markdig.dll": "sha256-34Ry04hh+o21Q3VDOJoD0lmCasZYDBsC9CvOeWz3BjI=",
"Markdig.SyntaxHighlighting.dll": "sha256-YEfO9OsS0T4kDjPXOW2pJF8qg62omn4UYMy/C2tcmC4=",
"Microsoft.AspNetCore.Authorization.dll": "sha256-IsV1p8+7qyVgHgqn8Yon3RZfqKDNjdC/kTwzUwtaAlY=",
Expand Down
Binary file modified _framework/blazor.boot.json.br
Binary file not shown.
Binary file modified _framework/blazor.boot.json.gz
Binary file not shown.
4 changes: 4 additions & 0 deletions css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ a,
border-style: solid;
}

.monaco-editor {
position: absolute !important;
}

#blazor-error-ui {
background-color: #1e1e1e;
bottom: 0;
Expand Down
195 changes: 163 additions & 32 deletions data/lessons/schema.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,120 @@
---
- id: 26b6ebca-58e6-4814-86ea-4946d844c9a8
background: |
JSON Schema is typically itself represented in JSON. To support this, the `JsonSchema`
type is completely compatible with the _System.Text.Json_ serializer.
docs: 'schema/basics/#schema-deserialization'
title: Deserializing a schema
instructions: |
Deserialize the text in `schemaText` into a `JsonSchema` variable called `schema`.
inputTemplate: ''
contextCode: |-
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using Json.Schema;
namespace LearnJsonEverything;
public class Lesson : ILessonRunner<EvaluationResults>
{
public EvaluationResults Run(JsonObject test)
{
var instance = test["instance"];
var schemaText =
"""
{
"type": "object",
"properties": {
"foo": { "type": "number", "minimum": 0 },
"bar": { "type": "string" }
},
"required": ["foo", "bar"]
}
""";
/* USER CODE */
return schema.Evaluate(instance);
}
}
tests:
- instance: { "foo": 13, "bar": "a string" }
isValid: true
- instance: { "foo": false, "bar": "a string" }
isValid: false
- instance: { "foo": 13 }
isValid: false
- instance: { "bar": "a string" }
isValid: false
- instance: [1,2,3]
isValid: false
- instance: 6.8
isValid: false
- id: 26b6ebca-58e6-4824-86ea-4946d844c9a8
skip: true
background: |
JSON Schema is typically itself represented in JSON. To support this, the `JsonSchema`
type is completely compatible with the _System.Text.Json_ serializer.
When compiling a Native AOT application or when trimming assemblies, you'll need to add
`JsonSchema` and `EvaluationOptions` to your serializer context in order to support
source generation.
docs: 'schema/basics/#aot'
title: Deserializing a schema (AOT)
instructions: |
Create a serializer context class called `MySerializerContext` and add the appropriate
attributes.
inputTemplate: ''
contextCode: |-
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using Json.Schema;
namespace LearnJsonEverything;
public class Lesson : ILessonRunner<EvaluationResults>
{
public EvaluationResults Run(JsonObject test)
{
var instance = test["instance"];
var schemaText =
"""
{
"type": "object",
"properties": {
"foo": { "type": "number", "minimum": 0 },
"bar": { "type": "string" }
},
"required": ["foo", "bar"]
}
""";
JsonSerializer.Deserialize(schemaText, MySerializerContext.Default.JsonSchema);
return schema.Evaluate(instance);
}
}
/* USER CODE */
tests:
- instance: { "foo": 13, "bar": "a string" }
isValid: true
- instance: { "foo": false, "bar": "a string" }
isValid: false
- instance: { "foo": 13 }
isValid: false
- instance: { "bar": "a string" }
isValid: false
- instance: [1,2,3]
isValid: false
- instance: 6.8
isValid: false
- id: 26b6ebca-58e6-4814-86ea-4946d844c9a6
title: 'Schema Builder: Any string'
background: |
Expand All @@ -21,9 +137,9 @@
public class Lesson : ILessonRunner<EvaluationResults>
{
public EvaluationResults Run(JsonObject context)
public EvaluationResults Run(JsonObject test)
{
var instance = context["instance"];
var instance = test["instance"];
var builder = new JsonSchemaBuilder();
/* USER CODE */
Expand Down Expand Up @@ -64,9 +180,9 @@
public class Lesson : ILessonRunner<EvaluationResults>
{
public EvaluationResults Run(JsonObject context)
public EvaluationResults Run(JsonObject test)
{
var instance = context["instance"];
var instance = test["instance"];
var builder = new JsonSchemaBuilder();
/* USER CODE */
Expand Down Expand Up @@ -123,9 +239,9 @@
public class Lesson : ILessonRunner<EvaluationResults>
{
public EvaluationResults Run(JsonObject context)
public EvaluationResults Run(JsonObject test)
{
var instance = context["instance"];
var instance = test["instance"];
var builder = new JsonSchemaBuilder();
/* USER CODE */
Expand All @@ -151,14 +267,16 @@
isValid: false
- instance: false
isValid: false
- id: 26b6ebca-58e6-4814-86ea-4946d844c9a8
- id: 26b6ebca-58e6-4814-86ea-4946d444c9a8
background: |
The `JsonSchemaBuilder` class provides a type-safe fluent interface. Adding a keyword is
accomplished by calling the same-name (usually) extension method.
docs: 'schema/basics/#schema-deserialization'
title: Deserializing a schema
By default, JSON Schema doesn't validate the `format` keyword. Instead, tools
are generally encouraged to provide a configuration option to enforce `format` validation.
In _JsonSchema.Net_ that option is called `RequiredFormatValidation`.
docs: 'schema/basics/#schema-format'
title: 'Options: Validating Formats'
instructions: |
Deserialize the text in `schemaText` into a `JsonSchema` variable called `schema`.
Configure the evaluation options to enable `format` validation.
inputTemplate: ''
contextCode: |-
using System;
Expand All @@ -172,36 +290,49 @@
public class Lesson : ILessonRunner<EvaluationResults>
{
public EvaluationResults Run(JsonObject context)
public EvaluationResults Run(JsonObject test)
{
var instance = context["instance"];
var schemaText =
"""
{
"type": "object",
"properties": {
"foo": { "type": "number", "minimum": 0 },
"bar": { "type": "string" }
},
"required": ["foo", "bar"]
}
""";
var instance = test["instance"];
var format = test["format"].GetValue<string>();
JsonSchema schema = new JsonSchemaBuilder()
.Type(SchemaValueType.String)
.Format(format);
var options = new EvaluationOptions();
/* USER CODE */
return schema.Evaluate(instance);
return schema.Evaluate(instance, options);
}
}
tests:
- instance: { "foo": 13, "bar": "a string" }
- instance: 2015-06-13T10:31:16+04:00
format: date-time
isValid: true
- instance: { "foo": false, "bar": "a string" }
- instance: 2015-06-13
format: date-time
isValid: false
- instance: { "foo": 13 }
- instance: 1.1.1.1
format: ipv4
isValid: true
- instance: www.google.com
format: ipv4
isValid: false
- instance: { "bar": "a string" }
- instance: '/json/pointer'
format: json-pointer
isValid: true
- instance: '/inva~lid/pointer'
format: json-pointer
isValid: false
- instance: [1,2,3]
# - instance: '0/json/pointer'
# format: relative-json-pointer
# isValid: true
- instance: {}
format: date-time
isValid: false
- instance: []
format: date-time
isValid: false
- instance: 6.8
isValid: false
format: date-time
isValid: false
8 changes: 6 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="description" content="Extended JSON support in .Net built on top of the System.Text.Json namespace">
<meta name="description" content="An interactive guide to utilizing JSON in .Net">
<title>Learn json-everything.net</title>
<base href="/" />
<script type="text/javascript">
Expand Down Expand Up @@ -64,7 +64,7 @@

<body>
<div id="app">
<p class="slogan">Extended JSON support in .Net built on top of the System.Text.Json namespace</p>
<p class="slogan">An interactive guide to utilizing JSON in .Net</p>
<div class="loading-message-container">
<div class="loading-message-child">
<img src="img/json-animated.webp" class="loading-image" /><br />
Expand Down Expand Up @@ -92,6 +92,10 @@
});
}
}
function BlazorScrollToTopOfElement(elementId) {
var element = document.getElementById(elementId);
element.scrollTop = 0;
}
</script>
<script src="_framework/blazor.webassembly.js"></script>
</body>
Expand Down
8 changes: 6 additions & 2 deletions json-schema/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="description" content="Extended JSON support in .Net built on top of the System.Text.Json namespace">
<meta name="description" content="An interactive guide to utilizing JSON in .Net">
<title>Learn json-everything.net</title>
<base href="/" />
<script type="text/javascript">
Expand Down Expand Up @@ -64,7 +64,7 @@

<body>
<div id="app">
<p class="slogan">Extended JSON support in .Net built on top of the System.Text.Json namespace</p>
<p class="slogan">An interactive guide to utilizing JSON in .Net</p>
<div class="loading-message-container">
<div class="loading-message-child">
<img src="img/json-animated.webp" class="loading-image" /><br />
Expand Down Expand Up @@ -92,6 +92,10 @@
});
}
}
function BlazorScrollToTopOfElement(elementId) {
var element = document.getElementById(elementId);
element.scrollTop = 0;
}
</script>
<script src="_framework/blazor.webassembly.js"></script>
</body>
Expand Down

0 comments on commit edad082

Please sign in to comment.