Created
February 8, 2022 01:35
-
-
Save pmachapman/0c9d10d754abff6f0fb0abd54131dcb6 to your computer and use it in GitHub Desktop.
Parses a JSON file from Creeds.json into HTML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$url = "https://raw.githubusercontent.com/NonlinearFruit/Creeds.json/master/creeds/keachs_catechism.json" | |
$parts = $url.Split("/") | |
$index = $parts.count - 1 | |
$filename = $parts.GetValue($index).ToString().Replace("_", "-").Replace(".json", ".html") | |
$response = Invoke-WebRequest -Uri $url -UseBasicParsing | |
$creed = $response | ConvertFrom-Json | |
foreach ($data in $creed.data) | |
{ | |
"<li id=`"q$($data.Number)`">" | Out-File -FilePath $filename -Append | |
$question = $data.Question.Replace("'", "’") | |
"`t<strong>$($question)</strong><br>" | Out-File -FilePath $filename -Append | |
$answer = $data.Answer.Replace("'", "’") | |
"`t$($answer)" | Out-File -FilePath $filename -Append | |
"`t<div class=`"references`">" | Out-File -FilePath $filename -Append | |
foreach ($proof in $data.Proofs) | |
{ | |
$postParams = @{references="$($proof.References)"} | |
$referencesResponse = Invoke-WebRequest -Uri https://conglomo.azurewebsites.net/sort.php?api=1 -Method POST -Body $postParams | |
$references = $referencesResponse.Content | |
"`t`t$($references)" | Out-File -FilePath $filename -Append | |
} | |
"`t</div>" | Out-File -FilePath $filename -Append | |
"</li>" | Out-File -FilePath $filename -Append | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment