需要删除':'从JSON输出的特定现场值

发布于 2025-01-22 10:06:13 字数 1799 浏览 0 评论 0原文

我正在尝试从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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟燃烟灭 2025-01-29 10:06:13

继续我的评论,

我会施放此通用分类日期格式的字符串到[dateTime]对象,您可以按照自己的方式进行格式而不是切割在字符串的一部分之外

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

。 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..

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

Your example ends with the Z for Zulu Time (UTC + 00:00), but another value may look like 2022-04-12T13:38:05+08:00, so converting it to datetime would IMO be best.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文