How to test if JSON object is empty in Java

前端 未结 15 2285

The JSON object I\'m receiving looks like this:

[{\"foo1\":\"bar1\", \"foo2\":\"bar2\", \"problemkey\": \"problemvalue\"}]

What I\'m trying

15条回答
  •  囚心锁ツ
    2020-12-14 00:20

    @Test
    public void emptyJsonParseTest() {
        JsonNode emptyJsonNode = new ObjectMapper().createObjectNode();
        Assert.assertTrue(emptyJsonNode.asText().isEmpty());
    }
    

提交回复
热议问题