Skip to content

Commit a4501bc

Browse files
committed
one minor tweak wrt #180
1 parent ee1a1d0 commit a4501bc

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Diff for: yaml/src/main/java/com/fasterxml/jackson/dataformat/yaml/YAMLGenerator.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,10 @@ private boolean _valueNeedsQuoting(String name) {
979979
case 'N': // Null/NULL/N/No/NO
980980
case 'T': // True/TRUE
981981
case 'Y': // Y/Yes/YES
982-
return MUST_QUOTE_VALUES.contains(name);
982+
if (MUST_QUOTE_VALUES.contains(name)) {
983+
return true;
984+
}
985+
break;
983986
}
984987
return _valueHasQuotableChar(name);
985988
}

Diff for: yaml/src/test/java/com/fasterxml/jackson/dataformat/yaml/ser/GeneratorWithMinimizeTest.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,14 @@ public void testMinimizeQuotesWithStringsContainingSpecialChars() throws Excepti
124124
assertEquals("---\n" +
125125
"key: \"a}b\"", yaml);
126126

127-
content = Collections.singletonMap("key", "a,b");
128-
yaml = MINIM_MAPPER.writeValueAsString(content).trim();
127+
yaml = MINIM_MAPPER.writeValueAsString(Collections.singletonMap("key", "a,b")).trim();
129128
assertEquals("---\n" +
130129
"key: \"a,b\"", yaml);
130+
131+
// plus also some edge cases (wrt "false" etc checking
132+
yaml = MINIM_MAPPER.writeValueAsString(Collections.singletonMap("key", "f:off")).trim();
133+
assertEquals("---\n" +
134+
"key: \"f:off\"", yaml);
131135
}
132136

133137
public void testLiteralStringsMultiLine() throws Exception

0 commit comments

Comments
 (0)