【发布时间】:2023-03-26 21:44:01
【问题描述】:
我想从下面的 json 中获取针对“名称”字段的值。我尝试使用工具http://jsonpathfinder.com/ 和http://jsonpath.com/? 我正在使用http://jsonpath.herokuapp.com/ 来验证表达式路径是否正确,但它总是将我返回为不正确的表达式。
{
"data" : {
"PensionRetriever(Customer=ABC, typeInfo=valid)" : {
"name" : "lifeInsurance",
"created_at" : 1552297775384,
"attributes" : [ {
"id" : "4044da39-c23b-4588-b6c4-975ce02e7cb2",
"name" : "lifeInsurance",
"created_at" : 1552297775384
}]
}
}
}
我尝试使用 $.data["PensionRetriever(Customer=ABC, typeInfo=valid)"].name ,但这似乎不正确。你能告诉我现在获取 "name" 的值,即 lifeInsurance
【问题讨论】:
-
当您拨打
$.data["PensionRetriever(Customer=ABC, typeInfo=valid)"].name时,incorrect是什么意思?当你调用console.log($.data)时返回什么? -
它给了我“在索引 55 处找到空属性”
标签: java json jsonpath json-path-expression