【问题标题】:I need to get a a specific value from Json file using powershell我需要使用 powershell 从 Json 文件中获取特定值
【发布时间】:2020-01-28 06:37:33
【问题描述】:

我使用这个命令 ConvertTo-Json 将记事本内的纯文本转换为 JSON 文件; 那么如何获取与记事本文本内容等效的特定键值呢?

    get-content -Path c:\Users\ayyub\oneDrive\Desktop\Jayson.txt | ConvertTo- 
    Json  

【问题讨论】:

标签: json windows powershell


【解决方案1】:

假设你的 .json 看起来像这样:

{
    "person": {
        "kevin": {
            "phone": "00000099999"
        }
    }
}

将 .txt 转换为 .json 后,您可能可以尝试以下操作:

$json = (Get-Content "example.json" -Raw) | ConvertFrom-Json

$json.person.kevin.phone

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-02
    • 2022-11-15
    • 2020-01-02
    • 2019-10-03
    相关资源
    最近更新 更多