Fix toJson implementation in modules