mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-03 11:25:30 -04:00
Merge pull request #968 from marilynel/master
Update keepStrings behavior to reflect changes in keepBooleanAsString, keepNumberAsString
This commit is contained in:
commit
8e65eaa992
@ -224,6 +224,7 @@ public class XMLParserConfiguration extends ParserConfiguration {
|
|||||||
@Override
|
@Override
|
||||||
public XMLParserConfiguration withKeepStrings(final boolean newVal) {
|
public XMLParserConfiguration withKeepStrings(final boolean newVal) {
|
||||||
XMLParserConfiguration newConfig = this.clone();
|
XMLParserConfiguration newConfig = this.clone();
|
||||||
|
newConfig.keepStrings = newVal;
|
||||||
newConfig.keepNumberAsString = newVal;
|
newConfig.keepNumberAsString = newVal;
|
||||||
newConfig.keepBooleanAsString = newVal;
|
newConfig.keepBooleanAsString = newVal;
|
||||||
return newConfig;
|
return newConfig;
|
||||||
@ -241,6 +242,7 @@ public class XMLParserConfiguration extends ParserConfiguration {
|
|||||||
public XMLParserConfiguration withKeepNumberAsString(final boolean newVal) {
|
public XMLParserConfiguration withKeepNumberAsString(final boolean newVal) {
|
||||||
XMLParserConfiguration newConfig = this.clone();
|
XMLParserConfiguration newConfig = this.clone();
|
||||||
newConfig.keepNumberAsString = newVal;
|
newConfig.keepNumberAsString = newVal;
|
||||||
|
newConfig.keepStrings = newConfig.keepBooleanAsString && newConfig.keepNumberAsString;
|
||||||
return newConfig;
|
return newConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,6 +258,7 @@ public class XMLParserConfiguration extends ParserConfiguration {
|
|||||||
public XMLParserConfiguration withKeepBooleanAsString(final boolean newVal) {
|
public XMLParserConfiguration withKeepBooleanAsString(final boolean newVal) {
|
||||||
XMLParserConfiguration newConfig = this.clone();
|
XMLParserConfiguration newConfig = this.clone();
|
||||||
newConfig.keepBooleanAsString = newVal;
|
newConfig.keepBooleanAsString = newVal;
|
||||||
|
newConfig.keepStrings = newConfig.keepBooleanAsString && newConfig.keepNumberAsString;
|
||||||
return newConfig;
|
return newConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -794,6 +794,31 @@ public class XMLConfigurationTest {
|
|||||||
Util.compareActualVsExpectedJsonObjects(actualJsonOutput,expected);
|
Util.compareActualVsExpectedJsonObjects(actualJsonOutput,expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test keepStrings behavior when setting keepBooleanAsString, keepNumberAsString
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void test_keepStringBehavior() {
|
||||||
|
XMLParserConfiguration xpc = new XMLParserConfiguration().withKeepStrings(true);
|
||||||
|
assertEquals(xpc.isKeepStrings(), true);
|
||||||
|
|
||||||
|
xpc = xpc.withKeepBooleanAsString(true);
|
||||||
|
xpc = xpc.withKeepNumberAsString(false);
|
||||||
|
assertEquals(xpc.isKeepStrings(), false);
|
||||||
|
|
||||||
|
xpc = xpc.withKeepBooleanAsString(false);
|
||||||
|
xpc = xpc.withKeepNumberAsString(true);
|
||||||
|
assertEquals(xpc.isKeepStrings(), false);
|
||||||
|
|
||||||
|
xpc = xpc.withKeepBooleanAsString(true);
|
||||||
|
xpc = xpc.withKeepNumberAsString(true);
|
||||||
|
assertEquals(xpc.isKeepStrings(), true);
|
||||||
|
|
||||||
|
xpc = xpc.withKeepBooleanAsString(false);
|
||||||
|
xpc = xpc.withKeepNumberAsString(false);
|
||||||
|
assertEquals(xpc.isKeepStrings(), false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSON string cannot be reverted to original xml.
|
* JSON string cannot be reverted to original xml.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user