|
2 | 2 | external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml |
3 | 3 | Locale: en-US |
4 | 4 | Module Name: Microsoft.PowerShell.Utility |
5 | | -ms.date: 07/24/2024 |
| 5 | +ms.date: 04/29/2025 |
6 | 6 | online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/test-json?view=powershell-7.4&WT.mc_id=ps-gethelp |
7 | 7 | schema: 2.0.0 |
8 | 8 | title: Test-Json |
@@ -136,20 +136,16 @@ $schema = @' |
136 | 136 | } |
137 | 137 | } |
138 | 138 | '@ |
139 | | -'{"name": "Ashley", "age": "25"}' | Test-Json -Schema $schema |
| 139 | +'{"name": "Ashley", "age": "25"}' | Test-Json -Schema $schema -ErrorAction SilentlyContinue |
140 | 140 | ``` |
141 | 141 |
|
142 | 142 | ```Output |
143 | | -Test-Json: |
144 | | -Line | |
145 | | - 35 | '{"name": "Ashley", "age": "25"}' | Test-Json -Schema $schema |
146 | | - | ~~~~~~~~~~~~~~~~~~~~~~~~~ |
147 | | - | The JSON is not valid with the schema: Value is "string" but should be "integer" at '/age' |
148 | 143 | False |
149 | 144 | ``` |
150 | 145 |
|
151 | | -In this example, we get an error because the schema expects an integer for **age** but the JSON |
152 | | -input we tested uses a string value instead. |
| 146 | +In this example, we use the **ErrorAction** parameter to suppres the error message. Without this |
| 147 | +parameter the command also outputs an error because the schema expects an integer for **age** but |
| 148 | +the JSON input we tested uses a string value instead. |
153 | 149 |
|
154 | 150 | For more information, see [JSON Schema](https://json-schema.org/). |
155 | 151 |
|
@@ -275,8 +271,8 @@ Accept wildcard characters: True |
275 | 271 | ### -Schema |
276 | 272 |
|
277 | 273 | Specifies a schema to validate the JSON input against. If passed, `Test-Json` validates that the |
278 | | -JSON input conforms to the spec specified by the **Schema** parameter and return `$true` only if the |
279 | | -input conforms to the provided schema. |
| 274 | +JSON input conforms to the specification defined by the **Schema** parameter and returns `$true` |
| 275 | +only if the input conforms to the provided schema. |
280 | 276 |
|
281 | 277 | For more information, see [JSON Schema](https://json-schema.org/). |
282 | 278 |
|
|
0 commit comments