Deal with boolean field (#18294)

This commit is contained in:
Beppe Catanese 2024-04-09 05:28:48 +02:00 committed by GitHub
parent 83b45fd1e8
commit 45a657f59d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -753,6 +753,9 @@ public class PostmanCollectionCodegen extends DefaultCodegen implements CodegenC
} 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);

View File

@ -602,11 +602,12 @@ public class PostmanCollectionCodegenTest {
@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));