Skip to content

Commit e5b1422

Browse files
author
James Brundage
committed
feat: Get-JsonJD - unrolling .'@graph' ( Fixes #2 )
1 parent 14202da commit e5b1422

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

Commands/Get-JsonLD.ps1

+9-7
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,20 @@ application/ld\+json # The type that indicates linked d
4545
ConvertFrom-Json
4646
) {
4747
if ($jsonObject.'@type') {
48-
$schemaType = $jsonObject.'@context',$jsonObject.'@type' -join '/'
48+
$schemaType = $jsonObject.'@context',$jsonObject.'@type' -ne '' -join '/'
4949
$jsonObject.pstypenames.insert(0, $schemaType)
50-
}
51-
52-
if ($jsonObject.'@graph') {
50+
$jsonObject
51+
} elseif ($jsonObject.'@graph') {
5352
foreach ($graphObject in $jsonObject.'@graph') {
54-
if ($graphObject.'@type') {
53+
if ($graphObject.'@type') {
5554
$graphObject.pstypenames.insert(0, $graphObject.'@type')
5655
}
57-
}
56+
$graphObject
57+
}
58+
} else {
59+
$jsonObject
5860
}
59-
$jsonObject
61+
6062
}
6163
}
6264
}

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# JSON-LD
2+
23
Get JSON Linked Data with PowerShell

0 commit comments

Comments
 (0)