Skip to content

Instantly share code, notes, and snippets.

@gitfvb
Created October 8, 2025 10:56
Show Gist options
  • Save gitfvb/7a21d3b09e98171746d34992061bd5a7 to your computer and use it in GitHub Desktop.
Save gitfvb/7a21d3b09e98171746d34992061bd5a7 to your computer and use it in GitHub Desktop.
How to use Newtonsoft json with PowerShell
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