Browse Source

Fix property json converter

pull/438/head
Ionite 10 months ago
parent
commit
f380a7676e
No known key found for this signature in database
  1. 8
      StabilityMatrix.Core/Converters/Json/ParsableStringValueJsonConverter.cs

8
StabilityMatrix.Core/Converters/Json/ParsableStringValueJsonConverter.cs

@ -42,9 +42,9 @@ public class ParsableStringValueJsonConverter<
JsonSerializerOptions options
)
{
if (reader.TokenType != JsonTokenType.String)
if (reader.TokenType != JsonTokenType.PropertyName)
{
throw new JsonException();
throw new JsonException("Unexpected token type");
}
var value = reader.GetString();
@ -87,11 +87,11 @@ public class ParsableStringValueJsonConverter<
if (value is IFormattable formattable)
{
writer.WriteStringValue(formattable.ToString(null, CultureInfo.InvariantCulture));
writer.WritePropertyName(formattable.ToString(null, CultureInfo.InvariantCulture));
}
else
{
writer.WriteStringValue(value.ToString());
writer.WritePropertyName(value.ToString());
}
}
}

Loading…
Cancel
Save