From d19133268e2513929f4ee842c2b58e073ba48b45 Mon Sep 17 00:00:00 2001 From: ikpil Date: Sat, 5 Aug 2023 20:21:53 +0900 Subject: [PATCH] change json library for unity3d --- src/DotRecast.Core/DotRecast.Core.csproj | 3 --- .../DotRecast.Detour.Extras.csproj | 4 ++++ .../Unity/Astar/GraphMetaReader.cs | 14 +++++++------- .../Unity/Astar/MetaReader.cs | 6 +++--- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/DotRecast.Core/DotRecast.Core.csproj b/src/DotRecast.Core/DotRecast.Core.csproj index eff52c8..d727bda 100644 --- a/src/DotRecast.Core/DotRecast.Core.csproj +++ b/src/DotRecast.Core/DotRecast.Core.csproj @@ -4,8 +4,5 @@ netstandard2.1 - - - diff --git a/src/DotRecast.Detour.Extras/DotRecast.Detour.Extras.csproj b/src/DotRecast.Detour.Extras/DotRecast.Detour.Extras.csproj index 2a71f47..6b37247 100644 --- a/src/DotRecast.Detour.Extras/DotRecast.Detour.Extras.csproj +++ b/src/DotRecast.Detour.Extras/DotRecast.Detour.Extras.csproj @@ -9,4 +9,8 @@ + + + + diff --git a/src/DotRecast.Detour.Extras/Unity/Astar/GraphMetaReader.cs b/src/DotRecast.Detour.Extras/Unity/Astar/GraphMetaReader.cs index 3ce4207..ce39281 100644 --- a/src/DotRecast.Detour.Extras/Unity/Astar/GraphMetaReader.cs +++ b/src/DotRecast.Detour.Extras/Unity/Astar/GraphMetaReader.cs @@ -18,7 +18,7 @@ freely, subject to the following restrictions: using System.IO; using System.IO.Compression; -using System.Text.Json; +using Newtonsoft.Json; namespace DotRecast.Detour.Extras.Unity.Astar { @@ -29,13 +29,13 @@ namespace DotRecast.Detour.Extras.Unity.Astar ZipArchiveEntry entry = file.GetEntry(filename); using StreamReader reader = new StreamReader(entry.Open()); - JsonSerializerOptions options = new JsonSerializerOptions - { - PropertyNamingPolicy = JsonNamingPolicy.CamelCase - }; - + // for unity3d var json = reader.ReadToEnd(); - return JsonSerializer.Deserialize(json, options); + return JsonConvert.DeserializeObject(json); + + // var settings = new JsonSerializerSettings(); + // settings.ContractResolver = new CamelCasePropertyNamesContractResolver(); + //return JsonConvert.DeserializeObject(json, settings); } } } \ No newline at end of file diff --git a/src/DotRecast.Detour.Extras/Unity/Astar/MetaReader.cs b/src/DotRecast.Detour.Extras/Unity/Astar/MetaReader.cs index 6ea88ea..686e7b7 100644 --- a/src/DotRecast.Detour.Extras/Unity/Astar/MetaReader.cs +++ b/src/DotRecast.Detour.Extras/Unity/Astar/MetaReader.cs @@ -19,9 +19,9 @@ freely, subject to the following restrictions: using System; using System.IO; using System.IO.Compression; -using System.Text.Json; -using System.Text.Json.Nodes; + using System.Text.RegularExpressions; +using Newtonsoft.Json; namespace DotRecast.Detour.Extras.Unity.Astar { @@ -41,7 +41,7 @@ namespace DotRecast.Detour.Extras.Unity.Astar var regex = new Regex(pattern); json = regex.Replace(json, replacement); - var meta = JsonSerializer.Deserialize(json); + var meta = JsonConvert.DeserializeObject(json); if (!meta.IsSupportedType()) { throw new ArgumentException("Unsupported graph type " + string.Join(", ", meta.typeNames));