forked from bit/DotRecastNetSim
change json library for unity3d
This commit is contained in:
parent
8ed6a86113
commit
d19133268e
|
@ -4,8 +4,5 @@
|
|||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Text.Json" Version="7.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -9,4 +9,8 @@
|
|||
<ProjectReference Include="..\DotRecast.Detour\DotRecast.Detour.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -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<GraphMeta>(json, options);
|
||||
return JsonConvert.DeserializeObject<GraphMeta>(json);
|
||||
|
||||
// var settings = new JsonSerializerSettings();
|
||||
// settings.ContractResolver = new CamelCasePropertyNamesContractResolver();
|
||||
//return JsonConvert.DeserializeObject<GraphMeta>(json, settings);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<Meta>(json);
|
||||
var meta = JsonConvert.DeserializeObject<Meta>(json);
|
||||
if (!meta.IsSupportedType())
|
||||
{
|
||||
throw new ArgumentException("Unsupported graph type " + string.Join(", ", meta.typeNames));
|
||||
|
|
Loading…
Reference in New Issue