1.jsonpath提取某个字段为指定值的其他字段数据
[
[
{
“code”: “a255e81dc5a5442e”,
“name”: “原始货号”,
“values”: [
{
“code”: “223e768a1b18b64c”,
“attrCode”: “a255e81dc5a5442e”,
“displayName”: “P11”,
“frontName”: “P11”,
“images”: [],
“originCode”: “P11”
}
],
“originCode”: “originalStyle”,
“subAttrs”: []
},
{
“code”: “695e92209e1fd511”,
“name”: “销售模式(可见)”,
“values”: [
{
“code”: “35e917b12f562394”,
“attrCode”: “695e92209e1fd511”,
“name”: “可见”,
“images”: [],
“originCode”: “0”
}
],
“originCode”: “customSalesModelVisible”,
“subAttrs”: []
},
{
“code”: “5f01da6db54ffbf2”,
“name”: “品牌季节”,
“values”: [
{
“code”: “e04bcb52d2cec01c”,
“attrCode”: “5f01da6db54ffbf2”,
“displayName”: “SS23”,
“frontName”: “SS23”,
“images”: [],
“originCode”: “SS23”
}
],
“originCode”: “BrandSeason”,
“subAttrs”: []
},
{
“code”: “6d7d57c330050cc4”,
“name”: “销售模式(可售)”,
“values”: [
{
“code”: “73c60c8892e5ae1e”,
“attrCode”: “6d7d57c330050cc4”,
“name”: “可售”,
“images”: [],
“originCode”: “0”
}
],
“originCode”: “customSalesModel”,
“subAttrs”: []
},
{
“code”: “84375ef911f92d9d”,
“name”: “商品名称”,
“values”: [
{
“code”: “4dcd532b6ebc7465”,
“attrCode”: “84375ef911f92d9d”,
“displayName”: “UNDERCOVER LAYERED JEAN”,
“frontName”: “UNDERCOVER LAYERED JEAN”,
“images”: [],
“originCode”: “UNDERCOVER LAYERED JEAN”
}
],
“originCode”: “productName”,
“subAttrs”: []
},
{
“code”: “93bc91f96ed1753e”,
“name”: “货号”,
“values”: [
{
“code”: “dfd1e5cf527b3a20”,
“attrCode”: “93bc91f96ed1753e”,
“displayName”: “SS23P11-GRY”,
“frontName”: “SS23P11-GRY”,
“images”: [],
“originCode”: “SS23P11-GRY”
}
],
“originCode”: “productNo”,
“subAttrs”: []
},
{
“code”: “293c1ecaf936c2cd”,
“name”: “官网挂件标记”,
“values”: [
{
“code”: “b02e8c3517803e55”,
“attrCode”: “293c1ecaf936c2cd”,
“name”: “是”,
“images”: [],
“originCode”: “true”
}
],
“originCode”: “isForWebsite”,
“subAttrs”: []
},
{
“code”: “36e7267d612bef4a”,
“name”: “品牌颜色”,
“values”: [
{
“code”: “8338f5d6c9972f3e”,
“attrCode”: “36e7267d612bef4a”,
“displayName”: “WASHD GRY”,
“frontName”: “WASHD GRY”,
“images”: [],
“originCode”: “WASHD GRY”
}
],
“originCode”: “BrandColor”,
“subAttrs”: []
}
]
]
json内容使用jsonpath提取 “name”: "原始货号"的value值和 name: “品牌季节” 的value值
要提取 “name”: “原始货号” 的 value 值和 “name”: "品牌要提取 “name”: “原始货号” 的 value 值和 “name”: “品牌季节” 的 value 值,可以使用以下 JSONPath 表达式:
$.[?(@.name==“原始货号”)].values[0].displayName
提取的值为:
[
“P11”
]
$.[?(@.name==“品牌季节”)].values[0].displayName
提取的值为:
[
“SS23”
]
2.jsonpath提取某个字段的所有值
{
“firstName”: “John”,
“lastName” : “doe”,
“age” : 26,
“address” : {
“streetAddress”: “naist street”,
“city” : “Nara”,
“postalCode” : “630-0192”
},
“phoneNumbers”: [
{
“type” : “iPhone”,
“number”: “0123-4567-8888”
},
{
“type” : “home”,
“number”: “0123-4567-8910”
}
]
}
提取 phoneNumbers 下的所有type值,可以使用以下 JSONPath 表达式:
$.phoneNumbers[*].type
提取的值为
[
“iPhone”,
“home”
]文章来源:https://www.toymoban.com/news/detail-816701.html
jsonpath在线解析器:http://www.atoolbox.net/Tool.php?Id=792
json在线格式化:https://www.json.cn/文章来源地址https://www.toymoban.com/news/detail-816701.html
到了这里,关于jsonpath提取字段某个字段为指定值的其他字段数据&提取某个字段的所有值的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!