Fix undefined behavior when accessing const json
Accessing a non-existing key in a const json object via the bracket operator is undefined behavior. Therefore, this commit replaces all key accesses with the at method which throws an exception if the key is missing.