Skip to content

Commit

Permalink
tweaks, fix spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
CypherPotato committed Nov 23, 2023
1 parent 204be91 commit 39b0195
Show file tree
Hide file tree
Showing 6 changed files with 279 additions and 49 deletions.
4 changes: 4 additions & 0 deletions Sources/LightJson/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[*.cs]
indent_style = tab
indent_size = tab
tab_size = 4
10 changes: 9 additions & 1 deletion Sources/LightJson/JsonObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@ public int Count
/// </summary>
public JsonObject()
{
this.properties = new Dictionary<string, JsonValue>();
if (JsonOptions.PropertyNameCaseInsensitive)
{
var comparer = StringComparer.OrdinalIgnoreCase;
this.properties = new Dictionary<string, JsonValue>(comparer);
}
else
{
this.properties = new Dictionary<string, JsonValue>();
}
}

/// <summary>
Expand Down
19 changes: 19 additions & 0 deletions Sources/LightJson/JsonOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace LightJson;

public static class JsonOptions
{
/// <summary>
/// Gets or sets a value that indicates whether a property's name uses a case-insensitive comparison when getting
/// values.
/// </summary>
public static bool PropertyNameCaseInsensitive { get; set; } = false;

/// <summary>
/// Gets or sets whether the JSON serializer should throw an exception when trying to convert a value to an invalid type.
/// </summary>
public static bool ThrowOnInvalidCast { get; set; } = false;
}

0 comments on commit 39b0195

Please sign in to comment.