File tree 2 files changed +28
-0
lines changed
2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -224,6 +224,7 @@ protected XMLParserConfiguration clone() {
224
224
@ Override
225
225
public XMLParserConfiguration withKeepStrings (final boolean newVal ) {
226
226
XMLParserConfiguration newConfig = this .clone ();
227
+ newConfig .keepStrings = newVal ;
227
228
newConfig .keepNumberAsString = newVal ;
228
229
newConfig .keepBooleanAsString = newVal ;
229
230
return newConfig ;
@@ -241,6 +242,7 @@ public XMLParserConfiguration withKeepStrings(final boolean newVal) {
241
242
public XMLParserConfiguration withKeepNumberAsString (final boolean newVal ) {
242
243
XMLParserConfiguration newConfig = this .clone ();
243
244
newConfig .keepNumberAsString = newVal ;
245
+ newConfig .keepStrings = newConfig .keepBooleanAsString && newConfig .keepNumberAsString ;
244
246
return newConfig ;
245
247
}
246
248
@@ -256,6 +258,7 @@ public XMLParserConfiguration withKeepNumberAsString(final boolean newVal) {
256
258
public XMLParserConfiguration withKeepBooleanAsString (final boolean newVal ) {
257
259
XMLParserConfiguration newConfig = this .clone ();
258
260
newConfig .keepBooleanAsString = newVal ;
261
+ newConfig .keepStrings = newConfig .keepBooleanAsString && newConfig .keepNumberAsString ;
259
262
return newConfig ;
260
263
}
261
264
Original file line number Diff line number Diff line change @@ -794,6 +794,31 @@ public void testToJSONArray_jsonOutput_withKeepBooleanAsString() {
794
794
Util .compareActualVsExpectedJsonObjects (actualJsonOutput ,expected );
795
795
}
796
796
797
+ /**
798
+ * Test keepStrings behavior when setting keepBooleanAsString, keepNumberAsString
799
+ */
800
+ @ Test
801
+ public void test_keepStringBehavior () {
802
+ XMLParserConfiguration xpc = new XMLParserConfiguration ().withKeepStrings (true );
803
+ assertEquals (xpc .isKeepStrings (), true );
804
+
805
+ xpc = xpc .withKeepBooleanAsString (true );
806
+ xpc = xpc .withKeepNumberAsString (false );
807
+ assertEquals (xpc .isKeepStrings (), false );
808
+
809
+ xpc = xpc .withKeepBooleanAsString (false );
810
+ xpc = xpc .withKeepNumberAsString (true );
811
+ assertEquals (xpc .isKeepStrings (), false );
812
+
813
+ xpc = xpc .withKeepBooleanAsString (true );
814
+ xpc = xpc .withKeepNumberAsString (true );
815
+ assertEquals (xpc .isKeepStrings (), true );
816
+
817
+ xpc = xpc .withKeepBooleanAsString (false );
818
+ xpc = xpc .withKeepNumberAsString (false );
819
+ assertEquals (xpc .isKeepStrings (), false );
820
+ }
821
+
797
822
/**
798
823
* JSON string cannot be reverted to original xml.
799
824
*/
You can’t perform that action at this time.
0 commit comments