需要删除':'从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输出中获取启动值 $ value = $ output.jobs.etr.tasks.initiatedon
,它给我值2022-04-12T13:38:05Z,但我需要删除:从值中。
谢谢你, 湿婆
I am trying to remove the : from the specific field value from the json output.
Please find the json output:
{
"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"
}
]
}
I am taking the initiatedOn value from the json output by
$value = $Output.jobs.etrs.tasks.initiatedOn
which giving me value 2022-04-12T13:38:05Z but I need to remove : from the value.
Thank you,
Shivam
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
继续我的评论,
我会施放此通用分类日期格式的字符串到
[dateTime]
对象,您可以按照自己的方式进行格式而不是切割在字符串的一部分之外。 08:00 ,因此将其转换为DateTime是最好的。
Continuing from my comment,
I would cast this universal sortable date formatted string into a
[datetime]
object, which you can format as you like instead of cutting off part of the string..Your example ends with the
Z
for Zulu Time (UTC + 00:00), but another value may look like2022-04-12T13:38:05+08:00
, so converting it to datetime would IMO be best.