我正在试图将JsonPath的this example转换为Scala。它应该很容易与Java类似:对Java库重载定义的模糊引用
List<String> authors = JsonPath.read(json, "$.store.book[*].author");
这我转换到这个斯卡拉:
val authors = JsonPath.read(json, "$.store.book[*].author");
凡JSON是一个字符串。但我得到这个编译错误。
ambiguous reference to overloaded definition, both method read in object JsonPath of type [T](x$1: String,
x$2: String, x$3: <repeated...>[com.jayway.jsonpath.Filter[_]])T and method read in object JsonPath of type
[T](x$1: Any, x$2: String, x$3: <repeated...>[com.jayway.jsonpath.Filter[_]])T match argument types
(String,String)
我以为是关系到
public static <T> T read(Object json, String jsonPath, Filter... filters)
和
public static <T> T read(String json, String jsonPath, Filter... filters)
从com.jayway.jsonpath.JsonPath(0.9.1版本)。
如何消除此函数调用的歧义?
看起来像* JsonPath *库中的一个问题,因为第一个参数中的字符串总是不明确的。 – MKaama