Skip to content

Commit

Permalink
Keep dictionary casing.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Mar 22, 2021
1 parent 346e445 commit f5038b6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ await log.DoSafeAsync($"Exporting Assets ({assetBatch})", async () =>
});
}

var pathCache = new Dictionary<string, string>();
var tree = new FolderTree(session);

await session.Assets.GetAllAsync(session.App, async asset =>
{
assets.Add(await asset.ToModelAsync(session, pathCache));
assets.Add(await asset.ToModelAsync(tree));

if (assets.Count > 50)
{
Expand Down
8 changes: 7 additions & 1 deletion cli/Squidex.CLI/Squidex.CLI/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ public static class Helper

static Helper()
{
SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
SerializerSettings.Converters.Add(new StringEnumConverter());
SerializerSettings.ContractResolver = new DefaultContractResolver
{
NamingStrategy = new CamelCaseNamingStrategy
{
ProcessDictionaryKeys = false
}
};
SerializerSettings.Formatting = Formatting.Indented;

Serializer = JsonSerializer.Create(SerializerSettings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Squidex.ClientLibrary.Utils;
using Xunit;

Expand Down Expand Up @@ -141,6 +142,19 @@ public void Should_serialize_invariant()
Assert.Contains("\"iv\": \"hello\"", serialized);
}

[Fact]
public void Should_serialize_dynamic_properties_with_original_casing()
{
var source = new DynamicData
{
["Property1"] = new JObject()
};

var serialized = source.ToJson();

Assert.Contains("\"Property1\": {}", serialized);
}

[Fact]
public void Should_deserialize_invariant()
{
Expand Down

0 comments on commit f5038b6

Please sign in to comment.