I have this JSON:
'{
"fibo": {
"2": { "hi": "there" },
"8": { "and": "you?" }
"5": { "well": "doing fine" },
"3": { "what": "is hap?" },
}
}'
And I want for instance to extract the last element (the { "what": "is hap?" } object), in the simplest manner possible (preferably one-liner with piping, without foreach-ing it).
I tried:
'{
"fibo": {
"2": { "hi": "there" },
"8": { "and": "you?" }
"5": { "well": "doing fine" },
"3": { "what": "is hap?" },
}
}' | ConvertFrom-Json | select { $_.fibo } | select -Last 1
But the select -Last 1 seems to be doing nothing.
I can use select { $_.fibo. } which works, but tomorrow that object may change to e.g.:
'{
"fibo": {
"2": { "hi": "there" },
"8": { "and": "you?" }
"5": { "well": "doing fine" },
"314": { "what": "is hap?" },
}
}'
so I cannot rely on that..