Class JsonConfigurationFileEncoder
Encodes selected string values directly in JSON configuration files.
Inherited Members
Namespace: Eigenverft.NetLib.Infrastructure.Hosting.Configuration.Values
Assembly: Eigenverft.NetLib.Infrastructure.dll
Syntax
public static class JsonConfigurationFileEncoder
Methods
| Edit this page View SourceEncodeMatchingValuesInPlace(string, IEnumerable<string>, ConfigurationValueCodec, bool)
Encodes values whose complete configuration paths match any supplied glob pattern.
Declaration
public static int EncodeMatchingValuesInPlace(string jsonFilePath, IEnumerable<string> keyPathPatterns, ConfigurationValueCodec codec, bool nullAsEmpty = true)
Parameters
| Type | Name | Description |
|---|---|---|
| string | jsonFilePath | The JSON file that may be changed. |
| IEnumerable<string> | keyPathPatterns | Case-insensitive glob patterns for complete colon-separated configuration paths. |
| ConfigurationValueCodec | codec | The reversible codec applied to matching clear-text values. |
| bool | nullAsEmpty | Whether matching JSON null values are encoded as empty strings. |
Returns
| Type | Description |
|---|---|
| int | The number of values changed. |
Remarks
The file is rewritten only when at least one value changes. Rewriting uses formatted JSON and therefore removes comments, trailing commas and the original whitespace. Recognized encoded wrappers are left untouched, including wrappers created by another codec; codec migration requires an explicit decode-and-rewrite operation.
EncodeMatchingValuesInPlace(string, string, ConfigurationValueCodec, bool)
Encodes values whose complete configuration paths match one glob pattern.
Declaration
public static int EncodeMatchingValuesInPlace(string jsonFilePath, string keyPathPattern, ConfigurationValueCodec codec, bool nullAsEmpty = true)
Parameters
| Type | Name | Description |
|---|---|---|
| string | jsonFilePath | |
| string | keyPathPattern | |
| ConfigurationValueCodec | codec | |
| bool | nullAsEmpty |
Returns
| Type | Description |
|---|---|
| int |