Created
October 8, 2025 10:56
-
-
Save gitfvb/7a21d3b09e98171746d34992061bd5a7 to your computer and use it in GitHub Desktop.
How to use Newtonsoft json with PowerShell
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
add-type -path "C:\Program Files\Apteco\FastStats Service\Handel\Newtonsoft.Json.dll" | |
class DataItem { | |
[string]$id | |
[string]$name | |
} | |
# Define the main response class | |
class ApiResponse { | |
[int]$replyCode | |
[string]$replyText | |
[System.Collections.Generic.List[DataItem]]$data | |
} | |
$json = get-content -path ".\status_1.json" -Encoding utf8 -Raw | |
# Deserialize the JSON into an ApiResponse object | |
$response = [Newtonsoft.Json.JsonConvert]::DeserializeObject($json, [ApiResponse]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment