@@ -28,21 +28,21 @@ public static void Serialize(TextWriter tw, object data, bool serializeAsJson =
2828 serializer . Serialize ( tw , data ) ;
2929 }
3030
31- public static string Serialize ( object data , bool serializeAsJson = false , bool emitDefaultValues = false )
31+ public static string Serialize ( object data , bool serializeAsJson = false , bool formatJson = true , bool emitDefaultValues = false )
3232 {
3333 string result = null ;
3434
3535 if ( ! string . IsNullOrWhiteSpace ( data ? . ToString ( ) ) )
3636 using ( StringWriter writer = new StringWriter ( ) )
3737 {
3838 Serialize ( writer , data , serializeAsJson , emitDefaultValues ) ;
39- result = serializeAsJson ? JsonHelpers . FormatJson ( writer . ToString ( ) ) : writer . ToString ( ) ;
39+ result = serializeAsJson && formatJson ? JsonHelpers . FormatJson ( writer . ToString ( ) ) : writer . ToString ( ) ;
4040 }
4141
4242 return result ;
4343 }
4444
45- public static void SerializeFile ( string path , object data , bool serializeAsJson = false , bool emitDefaultValues = false )
45+ public static void SerializeFile ( string path , object data , bool serializeAsJson = false , bool formatJson = true , bool emitDefaultValues = false )
4646 {
4747 if ( ! serializeAsJson )
4848 {
@@ -51,7 +51,7 @@ public static void SerializeFile(string path, object data, bool serializeAsJson
5151 }
5252 else //gets formatted json
5353 {
54- string result = Serialize ( data , serializeAsJson , emitDefaultValues ) ;
54+ string result = Serialize ( data , serializeAsJson , formatJson , emitDefaultValues ) ;
5555 File . WriteAllText ( path , result ) ;
5656 }
5757 }
0 commit comments