0

我有一种方法可以比较两个 json。

import org.json.JSONException;
import org.junit.Test;
import org.skyscreamer.jsonassert.*;
import org.skyscreamer.jsonassert.comparator.CustomComparator;

public class TestClass {

    @Test
    public void jsonCompareTest() throws JSONException {
        JSONAssert.assertEquals("{x: 1, time:123}", "{x: 1, time:234}",
                                new CustomComparator(
                                JSONCompareMode.LENIENT,
                                Customization.customization("time",
                                                            (ValueMatcher)(o1, o2) -> true)));
    }

}

所以它按预期工作,没有问题。但是,以下部分以黄色突出显示!

(ValueMatcher)(o1, o2) -> 真

它给出以下警告:

Unchecked assignment: 'org.skyscreamer.jsonassert.ValueMatcher' to 'org.skyscreamer.jsonassert.ValueMatcher<java.lang.Object>'
Signals places where an unchecked warning is issued by the compiler, for example:
    void f(HashMap map) {
        map.put("key", "value");
    }

如果我将以下内容放在类上方,它就会消失:

@SuppressWarnings("未选中")

但是有没有其他方法可以正确修复它而不是抑制警告?!

请在当前上下文中举例

4

0 回答 0