You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
The text was updated successfully, but these errors were encountered:
liverliu
changed the title
对于list的处理,当取值为null的时候,是否可以增加一个选项设置把null value设置到list里面,而不是直接忽略
JSONPath对于list的处理,当取值为null的时候,是否可以增加一个选项设置把null value设置到list里面,而不是直接忽略
Jan 5, 2021
对如下数据使用:JSONPath.eval(json, "$.data.dataRows[*].dataFields[*].value"),返回了6个元素的list,是否可以增加一种配置可以返回7个元素的list,其中首元素是null;当前默认的忽略处理,业务代码里面无法正确的映射元素的顺序,导致错误。
也就是希望有种方式,能让我取出的list是下面这种形式:
[null,"C3736",1621126800000,"**","29***6",1605456000000,"240397"]
而不是现在这样:
["C3736",1621126800000,"**","29***6",1605456000000,"240397"]
jayway的jsonpath是有这种能力的
Configuration conf = Configuration.defaultConfiguration().addOptions(Option.DEFAULT_PATH_LEAF_TO_NULL);
return JsonPath.using(conf).parse(json).read(path);
{
"data": {
"dataRows": [
{
"dataFields": [
{
"id": 1332,
"name": "gmtRegular",
"status": "success",
"valueType": "DATE"
},
{
"id": 302,
"name": "deptNo",
"status": "success",
"value": "C3736",
"valueType": "STRING"
},
{
"id": 143,
"name": "gmtOrigRegular",
"status": "success",
"value": 1621126800000,
"valueType": "DATE"
},
{
"id": 135,
"name": "name",
"status": "success",
"value": "",
"valueType": "STRING"
},
{
"id": 133,
"name": "workNo",
"status": "success",
"value": "29*6",
"valueType": "STRING"
},
{
"id": 140,
"name": "gmtEntry",
"status": "success",
"value": 1605456000000,
"valueType": "DATE"
},
{
"id": 199,
"name": "superWorkNo",
"status": "success",
"value": "240397",
"valueType": "STRING"
}
]
}
]
},
"status": "success",
"success": true
}
The text was updated successfully, but these errors were encountered: