Skip to content

Commit

Permalink
Fixes #182. Negative numbers serialized with quotes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dpbevin authored and cowtowncoder committed Mar 17, 2020
1 parent d692916 commit c164c6e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ private Feature(boolean defaultState) {

protected final static long MIN_INT_AS_LONG = (long) Integer.MIN_VALUE;
protected final static long MAX_INT_AS_LONG = (long) Integer.MAX_VALUE;
protected final static Pattern PLAIN_NUMBER_P = Pattern.compile("[0-9]*(\\.[0-9]*)?");
protected final static Pattern PLAIN_NUMBER_P = Pattern.compile("-?[0-9]*(\\.[0-9]*)?");
protected final static String TAG_BINARY = Tag.BINARY.toString();

// for field names, leave out quotes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ public void testQuoteNumberStoredAsString() throws Exception

assertEquals("---\n" +
"key: 2.0.1.2.3", yaml);

content.clear();
content.put("key", "-60");
yaml = mapper.writeValueAsString(content).trim();

assertEquals("---\n" +
"key: \"-60\"", yaml);
}

public void testNonQuoteNumberStoredAsString() throws Exception
Expand Down

0 comments on commit c164c6e

Please sign in to comment.