$darkmode
#include <sol.hpp>
Unfortunately, the way that sol is implemented, when json j = lua["key"], lua["key"].operator json&() is called, which leads to an error if lua["key"] is anything other than the usertype json.
For this reason, it's required to wrap any table access with something that turns it into a sol::object:
json j1 = lua["key"].template get<sol::object>(); json j2 = sol::object(lua["key"]);