Skip to content

Commit

Permalink
Fix build when variable contains null (#162)
Browse files Browse the repository at this point in the history
Fixes the object reference exception when referenced variable contains
null as value.
  • Loading branch information
Carael authored Jan 12, 2024
1 parent 463f8d6 commit 3584891
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Confix.Tool/src/Confix.Library/Variables/JsonParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ namespace Confix.Variables;

public static class JsonParser
{
public static Dictionary<string, JsonNode?> ParseNode(JsonNode node)
public static Dictionary<string, JsonNode?> ParseNode(JsonNode? node)
=> node switch
{
JsonArray array => ParseArray(array).ToDictionary(),
JsonObject obj => ParseObject(obj).ToDictionary(),
JsonValue => throw new JsonParserException("Node must be an JsonObject or JsonArray"),
null => new Dictionary<string, JsonNode?>{ {"", null} },
_ => throw new JsonParserException($"Cant parse type {node.GetType().Name}")
};

Expand Down

0 comments on commit 3584891

Please sign in to comment.