public static Map<String, String> getStringMapNullableValues(String property, JsonNode node) {
    Preconditions.checkArgument(node.has(property), "Cannot parse missing map: %s", property);
    JsonNode pNode = node.get(property);
    Preconditions.checkArgument(
        pNode != null && !pNode.isNull() && pNode.isObject(),
        "Cannot parse string map from non-object value: %s: %s",
        property,
        pNode);

    Map<String, String> map = Maps.newHashMap();
    Iterator<String> fields = pNode.fieldNames();
    while (fields.hasNext()) {
      String field = fields.next();
      map.put(field, getStringOrNull(field, pNode));
    }

    return map;
  }
@Test
  public void getStringMapNullableValues() throws JsonProcessingException {
    assertThatThrownBy(
            () -> JsonUtil.getStringMapNullableValues("items", JsonUtil.mapper().readTree("{}")))
        .isInstanceOf(IllegalArgumentException.class)
        .hasMessage("Cannot parse missing map: items");

    assertThatThrownBy(
            () ->
                JsonUtil.getStringMapNullableValues(
                    "items", JsonUtil.mapper().readTree("{\"items\": null}")))
        .isInstanceOf(IllegalArgumentException.class)
        .hasMessage("Cannot parse string map from non-object value: items: null");

    assertThatThrownBy(
            () ->
                JsonUtil.getStringMapNullableValues(
                    "items", JsonUtil.mapper().readTree("{\"items\": {\"a\":\"23\", \"b\":45}}")))
        .isInstanceOf(IllegalArgumentException.class)
        .hasMessage("Cannot parse to a string value: b: 45");

    Map<String, String> itemsWithNullableValues = Maps.newHashMap();
    itemsWithNullableValues.put("a", null);
    itemsWithNullableValues.put("b", null);
    itemsWithNullableValues.put("c", "23");
    assertThat(
            JsonUtil.getStringMapNullableValues(
                "items",
                JsonUtil.mapper()
                    .readTree("{\"items\": {\"a\": null, \"b\": null, \"c\": \"23\"}}")))
        .isEqualTo(itemsWithNullableValues);

    String json =
        JsonUtil.generate(
            gen -> {
              gen.writeStartObject();
              JsonUtil.writeStringMap("items", itemsWithNullableValues, gen);
              gen.writeEndObject();
            },
            false);

    assertThat(JsonUtil.getStringMapNullableValues("items", JsonUtil.mapper().readTree(json)))
        .isEqualTo(itemsWithNullableValues);
  }