Fix where we call to_json on context.