Skip to content

Commit

Permalink
Deal with boolean field (#18294)
Browse files Browse the repository at this point in the history
  • Loading branch information
gcatanese committed Apr 9, 2024
1 parent 83b45fd commit 45a657f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,9 @@ private String traverseMap(LinkedHashMap<String, Object> linkedHashMap, String r
} else if (value instanceof Integer) {
ret = ret + JSON_ESCAPE_DOUBLE_QUOTE + key + JSON_ESCAPE_DOUBLE_QUOTE + ": " +
value;
} else if (value instanceof Boolean) {
ret = ret + JSON_ESCAPE_DOUBLE_QUOTE + key + JSON_ESCAPE_DOUBLE_QUOTE + ": " +
value;
} else if (value instanceof LinkedHashMap) {
String in = ret + JSON_ESCAPE_DOUBLE_QUOTE + key + JSON_ESCAPE_DOUBLE_QUOTE + ": ";
ret = traverseMap(((LinkedHashMap<String, Object>) value), in);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,11 +602,12 @@ public void convertObjectNodeIncludingDoubleQuoteToJson() {
@Test
public void convertLinkedHashMapToJson() {

final String EXPECTED = "{\\n \\\"id\\\": 1,\\n \\\"city\\\": \\\"Amsterdam\\\"\\n}";
final String EXPECTED = "{\\n \\\"id\\\": 1,\\n \\\"city\\\": \\\"Amsterdam\\\",\\n \\\"safe\\\": true\\n}";

LinkedHashMap<String, Object> city = new LinkedHashMap<>();
city.put("id", 1);
city.put("city", "Amsterdam");
city.put("safe", true);

assertEquals(EXPECTED, new PostmanCollectionCodegen().convertToJson(city));

Expand Down

0 comments on commit 45a657f

Please sign in to comment.