Skip to content

Commit 10431c5

Browse files
committed
Made jsonmapper for dictionary use InvariantCulture
1 parent b2109bb commit 10431c5

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/LitJson/JsonMapper.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -779,10 +779,13 @@ private static void WriteValue (object obj, JsonWriter writer,
779779
return;
780780
}
781781

782-
if (obj is IDictionary) {
782+
if (obj is IDictionary dictionary) {
783783
writer.WriteObjectStart ();
784-
foreach (DictionaryEntry entry in (IDictionary) obj) {
785-
writer.WritePropertyName (entry.Key.ToString());
784+
foreach (DictionaryEntry entry in dictionary) {
785+
var propertyName = entry.Key is string key ?
786+
key
787+
: Convert.ToString(entry.Key, CultureInfo.InvariantCulture);
788+
writer.WritePropertyName (propertyName);
786789
WriteValue (entry.Value, writer, writer_is_private,
787790
depth + 1);
788791
}

0 commit comments

Comments
 (0)