The functions ifcondition, stringequals and stringcontains are currently throwing an exception when the first parameter is null. The first parameter would be null if the value of a node is passed as that first parameter and the node does is not actually present in the json document. The following sample code reproduces the behavior:
var input = @"{ ""id"": ""12345"" }";
var transformer = @"{
""#"": ""#valueof($)"",
""newName"": ""#ifcondition(#valueof($.name),,awesome,not awesome)""
}";
var output = new JsonTransformer().Transform(transformer, input);
//var jobj = JsonConvert.DeserializeObject(output);
//var pretty = JsonConvert.SerializeObject(jobj, Formatting.Indented);
//Console.WriteLine(pretty);
I believe this is not the best behavior. It should evaluate the conditionals to false, but not throw an exception.
I agree if EvaluationMode is set to 'FallbackToDefault', default value. If set to 'Strict' it should throw an exception, 'Strict' mode is exactly to prevent that, functions not able to complete successfully.
The functions ifcondition, stringequals and stringcontains are currently throwing an exception when the first parameter is null. The first parameter would be null if the value of a node is passed as that first parameter and the node does is not actually present in the json document. The following sample code reproduces the behavior:
I believe this is not the best behavior. It should evaluate the conditionals to false, but not throw an exception.
I will submit a PR with a suggestion on a fix.