Skip to content

remove calls used to json::empty used to check is keys exists and replace by json::contains

Matthias Wittgen requested to merge fix_json_empty into devel

Using the json/variant method empty to check for the existence of an object uses a side effect that defies const correctness. The typical usage: if(!j["key"].empty()) first creates the "key" is it doesn't exist. In that case "key" maps to an empty object. Instead j.contains("key") needs to used. With version 1.55 of variant chained keys can be checked by passing a string initializer list to contains. j.contains({"key1","key2"}) checks if j["key1"]["key2"] exists.

Merge request reports