3 ms·
The project that I am working is document-oriented, meaning that the schema cannot be well controlled. We end up with a lot of code is very guarded code that l
by cdumler 14y ago
The project that I am working is document-oriented, meaning that the schema cannot be well controlled. We end up with a lot of code is very guarded code that looks something like this:
if(((json.author || {}).lastPublish || {}).publishDate)) {
do something
}
It can be replaced with:
if(jsonPath(json, "$.author.lastPublish .publishDate")) {
do something
}
Or better, get all book publish dates, regardless of number of books, if any even exist, and those that might have a missing publishDate:
publishDates = jsonPath(json,"$.author.books[*].publishDate");