#### [Abblix\.Jwt](https://www.abblix.com/en/docs/api/abblix-jwt 'index')
### [Abblix\.Jwt](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt 'Abblix\.Jwt')

## JsonObjectExtensions Class

Provides extension methods for the [System\.Text\.Json\.Nodes\.JsonObject](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.nodes.jsonobject 'System\.Text\.Json\.Nodes\.JsonObject') class, enhancing its usability
by simplifying the process of accessing and manipulating JSON properties\.

```csharp
public static class JsonObjectExtensions
```

Inheritance [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') → JsonObjectExtensions

### Remarks
The extension methods in this class aim to streamline common tasks associated with JSON objects,
such as retrieving and setting properties with type safety and minimal boilerplate code\. These methods
abstract away some of the complexities of working directly with [System\.Text\.Json\.Nodes\.JsonObject](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.nodes.jsonobject 'System\.Text\.Json\.Nodes\.JsonObject') and [System\.Text\.Json\.Nodes\.JsonNode](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.nodes.jsonnode 'System\.Text\.Json\.Nodes\.JsonNode'),
offering a more fluent and intuitive interface for developers\.
### Methods

## JsonObjectExtensions\.GetProperty\<T\>\(this JsonObject, string\) Method {#Abblix.Jwt.JsonObjectExtensions.GetProperty_T_(thisSystem.Text.Json.Nodes.JsonObject,string)}

Retrieves the value of the specified property from a [System\.Text\.Json\.Nodes\.JsonObject](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.nodes.jsonobject 'System\.Text\.Json\.Nodes\.JsonObject')\.

```csharp
public static T? GetProperty<T>(this System.Text.Json.Nodes.JsonObject json, string name);
```
#### Type parameters

###### `T` {#Abblix.Jwt.JsonObjectExtensions.GetProperty_T_(thisSystem.Text.Json.Nodes.JsonObject,string).T}

The expected type of the property value\.
#### Parameters

###### `json` [System\.Text\.Json\.Nodes\.JsonObject](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.nodes.jsonobject 'System\.Text\.Json\.Nodes\.JsonObject') {#Abblix.Jwt.JsonObjectExtensions.GetProperty_T_(thisSystem.Text.Json.Nodes.JsonObject,string).json}

The [System\.Text\.Json\.Nodes\.JsonObject](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.nodes.jsonobject 'System\.Text\.Json\.Nodes\.JsonObject') instance to extract the property value from\.

###### `name` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Jwt.JsonObjectExtensions.GetProperty_T_(thisSystem.Text.Json.Nodes.JsonObject,string).name}

The name of the property whose value is to be retrieved\.

#### Returns
[T](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.JsonObjectExtensions#Abblix.Jwt.JsonObjectExtensions.GetProperty_T_(thisSystem.Text.Json.Nodes.JsonObject,string).T 'Abblix\.Jwt\.JsonObjectExtensions\.GetProperty\<T\>\(this System\.Text\.Json\.Nodes\.JsonObject, string\)\.T')  
The value of the specified property if it exists and can be successfully converted to the specified type;
otherwise, the default value for the type [T](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.JsonObjectExtensions#Abblix.Jwt.JsonObjectExtensions.GetProperty_T_(thisSystem.Text.Json.Nodes.JsonObject,string).T 'Abblix\.Jwt\.JsonObjectExtensions\.GetProperty\<T\>\(this System\.Text\.Json\.Nodes\.JsonObject, string\)\.T')\.

### Remarks
This method facilitates the retrieval of typed values from a JSON object, abstracting away the need
for manual type checking and conversion\.

## JsonObjectExtensions\.SetProperty\(this JsonObject, string, JsonNode\) Method {#Abblix.Jwt.JsonObjectExtensions.SetProperty(thisSystem.Text.Json.Nodes.JsonObject,string,System.Text.Json.Nodes.JsonNode)}

Sets or updates the value of a specified property in a [System\.Text\.Json\.Nodes\.JsonObject](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.nodes.jsonobject 'System\.Text\.Json\.Nodes\.JsonObject')\.

```csharp
public static System.Text.Json.Nodes.JsonObject SetProperty(this System.Text.Json.Nodes.JsonObject json, string name, System.Text.Json.Nodes.JsonNode? value);
```
#### Parameters

###### `json` [System\.Text\.Json\.Nodes\.JsonObject](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.nodes.jsonobject 'System\.Text\.Json\.Nodes\.JsonObject') {#Abblix.Jwt.JsonObjectExtensions.SetProperty(thisSystem.Text.Json.Nodes.JsonObject,string,System.Text.Json.Nodes.JsonNode).json}

The [System\.Text\.Json\.Nodes\.JsonObject](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.nodes.jsonobject 'System\.Text\.Json\.Nodes\.JsonObject') instance to modify\.

###### `name` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Jwt.JsonObjectExtensions.SetProperty(thisSystem.Text.Json.Nodes.JsonObject,string,System.Text.Json.Nodes.JsonNode).name}

The name of the property to set or update\.

###### `value` [System\.Text\.Json\.Nodes\.JsonNode](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.nodes.jsonnode 'System\.Text\.Json\.Nodes\.JsonNode') {#Abblix.Jwt.JsonObjectExtensions.SetProperty(thisSystem.Text.Json.Nodes.JsonObject,string,System.Text.Json.Nodes.JsonNode).value}

The new value for the property\. If `null`, the property is removed from the [System\.Text\.Json\.Nodes\.JsonObject](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.nodes.jsonobject 'System\.Text\.Json\.Nodes\.JsonObject')\.

#### Returns
[System\.Text\.Json\.Nodes\.JsonObject](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.nodes.jsonobject 'System\.Text\.Json\.Nodes\.JsonObject')

### Remarks
This method provides a convenient way to update the properties of a JSON object, allowing for
the addition of new properties or the removal of existing ones by providing a `null` value\.
It ensures that the JSON object remains in a consistent state by avoiding the presence of null property values\.
