需要从 json 输出的特定字段值中删除":"



我正试图从json输出的特定字段值中删除:

请找到json输出:

{
"suite_id": 111,
"object_type": 2,
"jobs": [
{
"jobId": 222,
"creationTime": "2022-04-12T13:38:02Z",
"browser": "chrome",
"browserVersion": "",
"platform": "win",
"platform_version": "",
"appiumVersion": "",
"deviceName": "",
"deviceOrientation": "",
"isSerial": false,
"totalExecutions": 1,
"isRetryExecAvailable": false,
"jobExecutionStatus": 1,
"etrs": {
"tasks": [
{
"executionId": 333,
"executionName": "Testing",
"executionStatus": "SUCCESS",
"restartExecutionStatus": "",
"restartExecutionId": 0,
"restartExecutionReportUrl": "",
"restartExecutionVideoUrl": "",
"initiatedOn": "2022-04-12T13:38:05Z",
"projectName": "Testproject",
"projectId": 1,
"executionVideoUrl": "",
"reportUrl": "avsfershd",
"testcaseId": 666,
"testCaseName": "testcase",
"errorsCount": 0,
"warningsCount": 0,
"statusMessage": "Success"
}
],
"total_execs": 0
},
"environmentType": "local"
}
]
}

我正在从json输出中获取initiatedOn值$value = $Output.jobs.etrs.tasks.initiatedOn

给我值2022-04-12T13:38:05Z,但我需要从值中删除:

谢谢你,11日

继续我的评论,

我会将这个通用的可排序日期格式字符串转换为[datetime]对象,您可以按照自己的喜好对其进行格式化,而不是切断字符串的一部分。

$value = '{0:yyyy-MM-dd}' -f [datetime]$Output.jobs.etrs.tasks.initiatedOn

您的示例以祖鲁时间(UTC + 00:00)的Z结束,但另一个值可能看起来像2022-04-12T13:38:05+08:00,因此将其转换为日期时间在我看来是最好的。

相关内容

  • 没有找到相关文章

最新更新