Skip to content

json 数组中类型转换错误 #190

@xfdev

Description

@xfdev

我有一个值为数组类型的json数据,例如:{"array":[1,2,3,4,5,6,7,8,9]} ,json数组中为 Number 类型,我想转换为 NSString 类型;
Model.h 声明
@property (nonatomic, copy) NSArray<NSString *> *array;

.m 实现方法:
+(nullable NSDictionary<NSString *, id> *)modelContainerPropertyGenericClass { return @{@"array" : [NSString class]}; }

但是转换后得到的 self.array 一直为一个空数组,不写 modelContainerPropertyGenericClass 方法或者类型制定为 {@"array" : [NSNumber class]} 可以正常获取数据,但不是想要的类型。
期待回复,谢谢!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions