更新时间:2022-11-18 18:44:59
检查每个值,然后手动将其转换为[NSNull null],然后再将其添加到数组?
Should I check every value, and manually convert it to [NSNull null] before add it to array?
是。您可以创建一个简单的帮助程序方法/函数:
Yes. You can create a simple helper method/function:
id GuardJSONElement(id arg) { return arg ? arg : [NSNull null]; }
然后:
[array addObject:GuardJSONElement(something)];