Compare commits
2 Commits
c75b7de439
...
2fe54da1c5
| Author | SHA1 | Date | |
|---|---|---|---|
| 2fe54da1c5 | |||
| 2ae163207c |
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace ToonSharp;
|
namespace ToonSharp;
|
||||||
|
|
||||||
@@ -9,6 +10,11 @@ namespace ToonSharp;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class ToonSerializer
|
public static class ToonSerializer
|
||||||
{
|
{
|
||||||
|
private static readonly JsonSerializerOptions jsonOptions = new()
|
||||||
|
{
|
||||||
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts the provided value to a TOON string.
|
/// Converts the provided value to a TOON string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -21,7 +27,7 @@ public static class ToonSerializer
|
|||||||
options ??= ToonSerializerOptions.Default;
|
options ??= ToonSerializerOptions.Default;
|
||||||
|
|
||||||
// Convert to JsonNode first for normalization
|
// Convert to JsonNode first for normalization
|
||||||
var jsonNode = JsonSerializer.SerializeToNode(value);
|
var jsonNode = JsonSerializer.SerializeToNode(value, jsonOptions);
|
||||||
|
|
||||||
var writer = new ToonWriter(options);
|
var writer = new ToonWriter(options);
|
||||||
return writer.Write(jsonNode);
|
return writer.Write(jsonNode);
|
||||||
@@ -75,7 +81,7 @@ public static class ToonSerializer
|
|||||||
public static TValue? Deserialize<TValue>(string toon, ToonSerializerOptions? options = null)
|
public static TValue? Deserialize<TValue>(string toon, ToonSerializerOptions? options = null)
|
||||||
{
|
{
|
||||||
var jsonNode = Deserialize(toon, options);
|
var jsonNode = Deserialize(toon, options);
|
||||||
return jsonNode is null ? default : jsonNode.Deserialize<TValue>();
|
return jsonNode is null ? default : jsonNode.Deserialize<TValue>(jsonOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<LangVersion>12</LangVersion>
|
<LangVersion>12</LangVersion>
|
||||||
|
|||||||
Reference in New Issue
Block a user