File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -6,23 +6,30 @@ namespace NFive.SDK.Core.Utilities
6
6
/// <summary>
7
7
/// Utilities to convert objects to and from JSON strings.
8
8
/// </summary>
9
- /// TODO: Convert to ISerializer interface and move Newtonsoft.Json requirement to higher level.
10
9
[ PublicAPI ]
11
10
public class Serializer
12
11
{
12
+ /// <summary>Gets or sets the formatting option for the serializer.</summary>
13
+ /// <value>The formatting option.</value>
14
+ public Formatting Formatting { get ; set ; } = Formatting . None ;
15
+
16
+ /// <summary>Gets or sets the settings for the serializer.</summary>
17
+ /// <value>The serializer settings.</value>
18
+ public JsonSerializerSettings Settings { get ; set ; }
19
+
13
20
/// <summary>
14
21
/// Serializes the specified object to JSON.
15
22
/// </summary>
16
23
/// <param name="obj">The object to serialize.</param>
17
24
/// <returns>The JSON representation of the object.</returns>
18
- public string Serialize ( object obj ) => JsonConvert . SerializeObject ( obj ) ;
25
+ public string Serialize ( object obj ) => JsonConvert . SerializeObject ( obj , this . Formatting , this . Settings ) ;
19
26
20
27
/// <summary>
21
28
/// Deserializes the specified JSON to a type.
22
29
/// </summary>
23
30
/// <typeparam name="T">The type to deserialize the JSON as.</typeparam>
24
31
/// <param name="json">The JSON to deserialize.</param>
25
32
/// <returns>The deserialized object.</returns>
26
- public T Deserialize < T > ( string json ) => JsonConvert . DeserializeObject < T > ( json ) ;
33
+ public T Deserialize < T > ( string json ) => JsonConvert . DeserializeObject < T > ( json , this . Settings ) ;
27
34
}
28
35
}
You can’t perform that action at this time.
0 commit comments