File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ function Get-JsonLD {
99 . EXAMPLE
1010 # Want to get information about a movie? Linked Data to the rescue!
1111 Get-JsonLD -Url https://www.imdb.com/title/tt0211915/
12+ . EXAMPLE
13+ # Want information about an article? Lots of news sites use this format.
14+ Get-JsonLD https://www.thebulwark.com/p/mahmoud-khalil-immigration-detention-first-amendment-free-speech-rights
1215 #>
1316 [Alias (' jsonLD' , ' json-ld' )]
1417 param (
@@ -41,13 +44,20 @@ application/ld\+json # The type that indicates linked d
4144 $match.Groups [' JsonContent' ].Value |
4245 ConvertFrom-Json
4346 ) {
44- if ($jsonObject .' @context ' -and $jsonObject . ' @ type' ) {
47+ if ($jsonObject .' @type' ) {
4548 $schemaType = $jsonObject .' @context' , $jsonObject .' @type' -join ' /'
46- $jsonObject.pstypenames.insert (0 , $schemaType )
49+ $jsonObject.pstypenames.insert (0 , $schemaType )
50+ }
51+
52+ if ($jsonObject .' @graph' ) {
53+ foreach ($graphObject in $jsonObject .' @graph' ) {
54+ if ($graphObject .' @type' ) {
55+ $graphObject.pstypenames.insert (0 , $graphObject .' @type' )
56+ }
57+ }
4758 }
4859 $jsonObject
4960 }
50- }
51-
61+ }
5262 }
5363}
You can’t perform that action at this time.
0 commit comments