forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJsonNumberHandling.cs
More file actions
54 lines (50 loc) · 2.64 KB
/
JsonNumberHandling.cs
File metadata and controls
54 lines (50 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Text.Json.Serialization
{
/// <summary>
/// Determines how <see cref="JsonSerializer"/> handles numbers when serializing and deserializing.
/// <remarks>
/// The behavior of <see cref="WriteAsString"/> and <see cref="AllowNamedFloatingPointLiterals"/> is not defined by the JSON specification. Altering the default number handling can potentially produce JSON that cannot be parsed by other JSON implementations.
/// </remarks>
/// </summary>
[Flags]
#if BUILDING_SOURCE_GENERATOR
internal
#else
public
#endif
enum JsonNumberHandling
{
/// <summary>
/// Numbers will only be read from <see cref="JsonTokenType.Number"/> tokens and will only be written as JSON numbers (without quotes).
/// </summary>
Strict = 0x0,
/// <summary>
/// Numbers can be read from <see cref="JsonTokenType.String"/> tokens.
/// Does not prevent numbers from being read from <see cref="JsonTokenType.Number"/> token.
/// Strings that have escaped characters will be unescaped before reading.
/// Leading or trailing trivia within the string token, including whitespace, is not allowed.
/// </summary>
AllowReadingFromString = 0x1,
/// <summary>
/// Numbers will be written as JSON strings (with quotes), not as JSON numbers.
/// <remarks>
/// This behavior is not defined by the JSON specification. Altering the default number handling can potentially produce JSON that cannot be parsed by other JSON implementations.
/// </remarks>
/// </summary>
WriteAsString = 0x2,
/// <summary>
/// The "NaN", "Infinity", and "-Infinity" <see cref="JsonTokenType.String"/> tokens can be read as
/// floating-point constants, and the <see cref="float"/> and <see cref="double"/> values for these
/// constants (such as <see cref="float.PositiveInfinity"/> and <see cref="double.NaN"/>)
/// will be written as their corresponding JSON string representations.
/// Strings that have escaped characters will be unescaped before reading.
/// Leading or trailing trivia within the string token, including whitespace, is not allowed.
/// <remarks>
/// This behavior is not defined by the JSON specification. Altering the default number handling can potentially produce JSON that cannot be parsed by other JSON implementations.
/// </remarks>
/// </summary>
AllowNamedFloatingPointLiterals = 0x4
}
}