0

I am learning some powershell with JSON and i have problem with get some value. I have file:

{
"expand":  "renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations",
"id":  "2966576",
"self":  "https://hostname/rest/api/2/issue/2966576",
"key":  "My_Key-369",
"fields":  {
               "subtasks":  [
                                "@{id=2966577; key=My_Key-370; self=https://hostname/rest/api/2/issue/2966577; fields=}",
                                "@{id=2966578; key=My_Key-371; self=https://hostname/rest/api/2/issue/2966578; fields=}",
                                "@{id=2966579; key=My_Key-372; self=https://hostname/rest/api/2/issue/2966579; fields=}",
                                "@{id=2966580; key=My_Key-373; self=https://hostname/rest/api/2/issue/2966580; fields=}",
                                "@{id=2966581; key=My_Key-374; self=https://hostname/rest/api/2/issue/2966581; fields=}",
                                "@{id=2966582; key=My_Key-375; self=https://hostname/rest/api/2/issue/2966582; fields=}",
                                "@{id=2966583; key=My_Key-376; self=https://hostname/rest/api/2/issue/2966583; fields=}",
                                "@{id=2966584; key=My_Key-377; self=https://hostname/rest/api/2/issue/2966584; fields=}",
                                "@{id=2966585; key=My_Key-378; self=https://hostname/rest/api/2/issue/2966585; fields=}",
                                "@{id=2966586; key=My_Key-379; self=https://hostname/rest/api/2/issue/2966586; fields=}",
                                "@{id=2966587; key=My_Key-380; self=https://hostname/rest/api/2/issue/2966587; fields=}",
                                "@{id=2966588; key=My_Key-381; self=https://hostname/rest/api/2/issue/2966588; fields=}",
                                "@{id=2966589; key=My_Key-382; self=https://hostname/rest/api/2/issue/2966589; fields=}",
                                "@{id=2966590; key=My_Key-383; self=https://hostname/rest/api/2/issue/2966590; fields=}"
                            ]
           }

}

I want have My_Key-*** in separate variables. I cant access to this subtasks table. Could you help me how can get this value?

3
  • 2
    What have you tried so far and what were the results? ConvertFrom-Json would be a good place to start. Commented Aug 3, 2022 at 10:45
  • 1
    As an aside, your subtasks entries look like they've been serialised incorrectly - they appear to contain a string representation of a PowerShell hashtable rather than a nested json object. This might result in data loss and difficulty deserialising the string, so you may need to review how you're generating the json file in the first place... Commented Aug 3, 2022 at 11:38
  • See also @mklement0’s answer here for pretty much the same issue in another question… stackoverflow.com/a/73242200/3156906 Commented Aug 4, 2022 at 22:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.