Skip to content

Commit fc1ee68

Browse files
committed
Fix #226
1 parent 8107723 commit fc1ee68

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

release-notes/VERSION-2.x

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Modules:
1515
#222: (csv) `JsonParser.Feature.EMPTY_STRING_AS_NULL` does not work when
1616
text is parsed as `String[]`
1717
(reported by wkwkhautbois@github)
18+
#226: Quote 'y'/'Y'/'n'/'N' as names too (to avoid problems with Boolean keys)
19+
(requested by pnepywoda@github)
1820
- Add Gradle Module Metadata (https://blog.gradle.org/alignment-with-gradle-module-metadata)
1921

2022
2.11.2 (02-Aug-2020)

yaml/src/main/java/com/fasterxml/jackson/dataformat/yaml/YAMLGenerator.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,9 @@ private Feature(boolean defaultState) {
178178
*/
179179
// 02-Apr-2019, tatu: Some names will look funny if escaped: let's leave out
180180
// single letter case (esp so 'y' won't get escaped)
181+
// 17-Sep-2020, tatu: [dataformats-text#226] No, let's be consistent w/ values
181182
private final static Set<String> MUST_QUOTE_NAMES = new HashSet<>(Arrays.asList(
182-
// "y", "Y", "n", "N",
183+
"y", "Y", "n", "N",
183184
"yes", "Yes", "YES", "no", "No", "NO",
184185
"true", "True", "TRUE", "false", "False", "FALSE",
185186
"on", "On", "ON", "off", "Off", "OFF"

yaml/src/test/java/com/fasterxml/jackson/dataformat/yaml/misc/ReservedNamesTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public void testQuotingOfBooleanKeys() throws Exception
1717
"false", "False",
1818
"yes", "no",
1919
// NOTE: single-letter cases left out on purpose
20-
// "y", "Y", "n", "N",
20+
"y", "Y", "n", "N",
2121
"on", "off",
2222
}) {
2323
_testQuotingOfBooleanKeys(value);

yaml/src/test/java/com/fasterxml/jackson/dataformat/yaml/ser/DatabindWriteTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,14 @@ public void testBasicPOJO() throws Exception
5858
assertFalse(it.hasNext());
5959
}
6060

61-
// Related to [dataformats-test#68], escaping of "reserved" names
61+
// Related to [dataformats-text#68], escaping of "reserved" names
6262
public void testBasicDatabind2() throws Exception
6363
{
6464
String yaml = trimDocMarker(MAPPER.writeValueAsString(new Point(1, 2)));
6565

6666
// Just verify 'y' will NOT be escaped
67-
assertEquals("x: 1\ny: 2", yaml);
67+
// [dataformats-text#226]: ... actually, will be.
68+
assertEquals("x: 1\n\"y\": 2", yaml);
6869

6970
// Actually let's try reading back, too
7071
Point p = MAPPER.readValue(yaml, Point.class);

0 commit comments

Comments
 (0)