[BUGFIX] Avoid serialisation of closure by using json_encode