FrendsPlatform / Frends.Json

FRENDS JSON Processing tasks, which allow you to do JSONPath queries, JSON Handlebars transformations, JSON Validation against a JSONSchema and converting various data formats to JSON.
MIT License
7 stars 4 forks source link

QuerySingle does not return anything(not even NULL) when not matched #14

Closed pekkatki closed 4 years ago

pekkatki commented 4 years ago

Case: some json elements are present based on certain conditions. When doing a query with Frends.Json.Json.QuerySingle (1.1.35) and no such element is found from the json structure(option "Error when not matched" = false), the task returns nothing.

See image below. There is no #result to be found. Not even a null value. This causes a problem when trying to e.g. in excl decision to find out whether the result was null or empty: !string.IsNullOrEmpty(#result[Json.QuerySingleTask].ToString()) causes an error: "Cannot perform runtime binding on a null reference"

image

EkiH commented 4 years ago

The error seems to be actually caused by

Result[Json.QuerySingleTask]

being null and then being called by .ToString() This was fixed by changing to

!string.IsNullOrEmpty((string)#Result[Json.QuerySingleTask]?.ToString())

which handles the null value. Closing this as a non-issue