@@ -606,8 +606,8 @@ public static T DeserializeObject<T>(string json)
606
606
public static string SerializeObject ( object json , IJsonSerializerStrategy jsonSerializerStrategy )
607
607
{
608
608
StringBuilder builder = new StringBuilder ( BUILDER_CAPACITY ) ;
609
- ResetIndentationLevel ( ) ;
610
609
bool success = SerializeValue ( jsonSerializerStrategy , json , builder ) ;
610
+ ResetIndentationText ( ) ;
611
611
return ( success ? builder . ToString ( ) : null ) ;
612
612
}
613
613
@@ -1239,20 +1239,20 @@ internal static object ReplaceUnsupportedNumericValues(object value)
1239
1239
}
1240
1240
}
1241
1241
1242
- private static int indentationLevel ;
1242
+ private const char WhiteSpaceCharacter = ' ' ;
1243
+ private static int indentationLevel = 0 ;
1243
1244
private static string indentationText ;
1244
1245
private static readonly int spacesPerIndent = 3 ;
1245
1246
1246
- private static void ResetIndentationLevel ( )
1247
+ private static void ResetIndentationText ( )
1247
1248
{
1248
- indentationLevel = 0 ;
1249
- indentationText = Environment . NewLine + new string ( ' ' , indentationLevel * spacesPerIndent ) ;
1249
+ indentationText = Environment . NewLine ;
1250
1250
}
1251
1251
1252
1252
private static void HandleIndent ( int change )
1253
1253
{
1254
1254
indentationLevel += change ;
1255
- indentationText = Environment . NewLine + new string ( ' ' , indentationLevel * spacesPerIndent ) ;
1255
+ indentationText = Environment . NewLine + new string ( WhiteSpaceCharacter , indentationLevel * spacesPerIndent ) ;
1256
1256
}
1257
1257
1258
1258
private static IJsonSerializerStrategy _currentJsonSerializerStrategy ;
0 commit comments