diff --git a/Lombiq.VueJs.Samples/Lombiq.VueJs.Samples.csproj b/Lombiq.VueJs.Samples/Lombiq.VueJs.Samples.csproj index de454923..9c7cb585 100644 --- a/Lombiq.VueJs.Samples/Lombiq.VueJs.Samples.csproj +++ b/Lombiq.VueJs.Samples/Lombiq.VueJs.Samples.csproj @@ -34,10 +34,10 @@ - - - - + + + + diff --git a/Lombiq.VueJs/Lombiq.VueJs.csproj b/Lombiq.VueJs/Lombiq.VueJs.csproj index cbc7fa12..37795b66 100644 --- a/Lombiq.VueJs/Lombiq.VueJs.csproj +++ b/Lombiq.VueJs/Lombiq.VueJs.csproj @@ -13,7 +13,7 @@ $(SolutionDir)src\Libraries\Lombiq.HelpfulLibraries\Lombiq.HelpfulLibraries.SourceGenerators\bin\Release\netstandard2.0\Lombiq.HelpfulLibraries.SourceGenerators.dll - + @@ -57,9 +57,9 @@ - - - + + + diff --git a/Lombiq.VueJs/Models/GetPageFromQueryResult.cs b/Lombiq.VueJs/Models/GetPageFromQueryResult.cs index 4f5f5112..4d1262ec 100644 --- a/Lombiq.VueJs/Models/GetPageFromQueryResult.cs +++ b/Lombiq.VueJs/Models/GetPageFromQueryResult.cs @@ -1,13 +1,16 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; using System.Collections.Generic; +using System.Text.Json.Serialization; namespace Lombiq.VueJs.Models; -[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] public class GetPageFromQueryResult { + [JsonPropertyName("items")] public IEnumerable Items { get; set; } + + [JsonPropertyName("pageSize")] public int PageSize { get; set; } + + [JsonPropertyName("pageCount")] public int PageCount { get; set; } } diff --git a/Lombiq.VueJs/Models/UrlAndText.cs b/Lombiq.VueJs/Models/UrlAndText.cs index c6d02697..c8df81da 100644 --- a/Lombiq.VueJs/Models/UrlAndText.cs +++ b/Lombiq.VueJs/Models/UrlAndText.cs @@ -1,11 +1,12 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; +using System.Text.Json.Serialization; namespace Lombiq.VueJs.Models; -[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] public class UrlAndText { + [JsonPropertyName("url")] public string Url { get; set; } + + [JsonPropertyName("text")] public string Text { get; set; } } diff --git a/Lombiq.VueJs/Services/ServerSideValuesVueSingleFileComponentShapeAmenderBase.cs b/Lombiq.VueJs/Services/ServerSideValuesVueSingleFileComponentShapeAmenderBase.cs index 18403a37..9787b212 100644 --- a/Lombiq.VueJs/Services/ServerSideValuesVueSingleFileComponentShapeAmenderBase.cs +++ b/Lombiq.VueJs/Services/ServerSideValuesVueSingleFileComponentShapeAmenderBase.cs @@ -1,8 +1,7 @@ using Microsoft.AspNetCore.Html; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; using System.Collections.Generic; using System.Linq; +using System.Text.Json; using System.Threading.Tasks; namespace Lombiq.VueJs.Services; @@ -20,6 +19,12 @@ namespace Lombiq.VueJs.Services; /// public abstract class ServerSideValuesVueSingleFileComponentShapeAmenderBase : IVueSingleFileComponentShapeAmender { + private static readonly JsonSerializerOptions _camelCaseJsonSerializerOptions = new() + { + WriteIndented = false, + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + }; + /// /// Gets the value used to compare in . If this value is then will be called on every Vue.js shape, otherwise only if its name is the value of > PrependAsync(string shapeName) { if (ShapeName != null && ShapeName != shapeName) return Enumerable.Empty(); - var values = await GetPropertyValueAsync(shapeName); - var json = JsonConvert.SerializeObject( - values, - Formatting.None, - new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); + var propertyName = JsonSerializer.Serialize(PropertyName); + var json = JsonSerializer.SerializeToNode(await GetPropertyValueAsync(shapeName), _camelCaseJsonSerializerOptions); return new[] { new HtmlString( ""), }; }