59
59
'{d:{a:{b:1,c:{"$ref":"#/d/c"}},c:{d:{"$ref":"#/d/two"}},two:2}}' |Select-Json.ps1 /*/a/c/* -FollowReferences
60
60
61
61
2
62
+
63
+ . EXAMPLE
64
+ Resolve-Path $env:LOCALAPPDATA/Packages/*WindowsTerminal*/LocalState/settings.json |Get-Item |Get-Content -Raw |Select-Json.ps1 /profiles/list/*/name
65
+
66
+ PowerShell
67
+ Windows PowerShell
68
+ Ubuntu
69
+ F# Interactive
70
+ F# REPL
71
+ C# REPL
72
+ Command Prompt
73
+ Media Server (ssh)
74
+ Azure Cloud Shell
75
+ Developer Command Prompt for VS 2022
76
+ Developer PowerShell for VS 2022
62
77
#>
63
78
64
79
# Requires -Version 7
@@ -153,10 +168,10 @@ Begin
153
168
if ($refUri ) {return Get-Reference - ReferenceUri $refUri - Root $Script :Root | Select-Pointer - Segments $Segments }
154
169
}
155
170
if (! $Segments.Count ) {return $InputObject }
156
- $segment , $Segments = $Segments
157
- if ($null -eq $Segments ) {[string []]$Segments = @ ()}
158
- if ($segment -match ' [?*[]' ) {Select-Wildcard $InputObject $segment | Select-Pointer - Segments $Segments }
159
- else {Select-Segment $InputObject $segment | Select-Pointer - Segments $Segments }
171
+ $segment , $tail = $Segments
172
+ if ($null -eq $tail ) {[string []]$tail = @ ()}
173
+ if ($segment -match ' [?*[]' ) {Select-Wildcard $InputObject $segment | Select-Pointer - Segments $tail }
174
+ else {Select-Segment $InputObject $segment | Select-Pointer - Segments $tail }
160
175
}
161
176
}
162
177
Process
@@ -172,9 +187,8 @@ Process
172
187
if ($InputObject -is [string ])
173
188
{
174
189
if ($InputObject.StartsWith (([char ]0xFEFF ))) {$InputObject = $InputObject.Substring (1 )}
175
- return $InputObject |
176
- ConvertFrom-Json - AsHashtable |
177
- Select-Json.ps1 - JsonPointer $JsonPointer - FollowReferences:$FollowReferences
190
+ return Select-Json.ps1 - JsonPointer $JsonPointer - FollowReferences:$FollowReferences `
191
+ - InputObject ($InputObject | ConvertFrom-Json - AsHashtable - NoEnumerate)
178
192
}
179
193
if (! $jsonpath.Length ) {return $InputObject }
180
194
$Script :Root = $InputObject
0 commit comments