Class JsonReader
Contains static methods to convert to JsonObject
Inheritance
object
JsonReader
Namespace: BuildSystem.Utils.Json
Assembly: BuildSystem.Utils.dll
Syntax
public class JsonReader : Object
Constructors
JsonReader()
Declaration
public JsonReader()
Methods
ReadByJObject(string, Dictionary<string, string?>)
Read .json file and replace in it according to rules. Works by simple string.Replace
Declaration
public static JsonObject? ReadByJObject(string jsonPath, Dictionary<string, string?> replaceVars)
Parameters
Type | Name | Description |
---|---|---|
string | jsonPath | Path to .json |
System.Collections.Generic.Dictionary<,><string, string> | replaceVars | Rules of replacing |
Returns
Type | Description |
---|---|
System.Text.Json.Nodes.JsonObject |
ReadByJObject(string)
Read the .json file using library Newtonsoft
Declaration
public static JsonObject ReadByJObject(string jsonPath)
Parameters
Type | Name | Description |
---|---|---|
string | jsonPath | Full path to reading file |
Returns
Type | Description |
---|---|
System.Text.Json.Nodes.JsonObject | JsonObject converted from file |
Exceptions
Type | Condition |
---|---|
System.IO.IOException | Reading file not found |
ReadByString(string, Dictionary<string, string?>)
Read string var as JSON object and replace in it according to rules.
Declaration
public static JsonObject? ReadByString(string inputText, Dictionary<string, string?> replaceVars)
Parameters
Type | Name | Description |
---|---|---|
string | inputText | String with JSON object |
System.Collections.Generic.Dictionary<,><string, string> | replaceVars | Rules of replacing |
Returns
Type | Description |
---|---|
System.Text.Json.Nodes.JsonObject |
ReadBySystemText(string)
Read the .json file using library System.Text.Json
Declaration
public static JsonObject ReadBySystemText(string jsonPath)
Parameters
Type | Name | Description |
---|---|---|
string | jsonPath | Full path to reading file |
Returns
Type | Description |
---|---|
System.Text.Json.Nodes.JsonObject | JsonObject converted from file |
Exceptions
Type | Condition |
---|---|
System.IO.IOException | Reading file not found |
ReadSection(JToken)
Recursive method which reads value of JToken
Declaration
public static JsonNode? ReadSection(JToken node)
Parameters
Type | Name | Description |
---|---|---|
Newtonsoft.Json.Linq.JToken | node | Reading JToken |
Returns
Type | Description |
---|---|
System.Text.Json.Nodes.JsonNode | Converted to JsonNode value |