简体   繁体   English

我需要使用 powershell 从 Json 文件中获取特定值

[英]I need to get a a specific value from Json file using powershell

I converted a plain text inside note-pad to JSON file using this command ConvertTo-Json;我使用此命令 ConvertTo-Json 将记事本内的纯文本转换为 JSON 文件; so how do I get the specific key value that equivalents to note-pad text content?那么如何获得与记事本文本内容等效的特定键值呢?

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

Let's say your.json looks like this:假设 your.json 看起来像这样:

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

After converting the.txt to a.json you can probably try this:将.txt 转换为 a.json 后,您可以尝试以下操作:

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

$json.person.kevin.phone

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM