我有这个来自 ASP MVC API 的 Json 我有 InvModel 和 LotModel
但是当我打电话时
_InvFeed = [[InvModel alloc] initFromURLWithString:@"http://192.168.1.206/service/api/dto/inventory/1?p=Red%20Globe"
completion:^(JSONModel *model, JSONModelError *err)
{
NSLog(@"Inventory: %@", _InvFeed );
NSLog(@"Error: %@",err);
}];
我无法弄清楚这个错误:
错误:错误域 = JSONModelErrorDomain 代码 = 1 “无效的 JSON 数据:尝试使用 initWithDictionary 初始化 JSONModel 对象:错误:但字典参数不是 'NSDictionary'。”
UserInfo=0x109075ff0 {NSLocalizedDescription=无效的 JSON 数据:尝试使用 initWithDictionary 初始化 JSONModel 对象:错误:但字典参数不是 'NSDictionary'。,kJSONModelKeyPath=LotDTO}
这里是 JSONModels:LotDTO
#import "JSONModel.h"
@interface InvLotModel : JSONModel
@property (assign, nonatomic) int lotid;
@property (strong, nonatomic) NSDate* expdate;
@property (strong, nonatomic) NSString* lotserial;
@property (strong, nonatomic) NSDate* lastupddate;
@property (strong, nonatomic) NSString<Optional>* providerlotserial;
@property (assign, nonatomic) NSDecimal* qtyoriginal;
@property (assign, nonatomic) NSDecimal* qtyallocated;
@property (assign, nonatomic) NSDecimal* qtyavailable;
@property (assign, nonatomic) NSDecimal* qtyonhand;
@property (strong, nonatomic) NSDate* receiptdate;
@property (strong, nonatomic) NSString* linecomment;
@property (assign, nonatomic) NSDecimal* unitcost;
@property (strong, nonatomic) NSString* warehouse;
@end
这里是库存模型
#import "JSONModel.h"
#import "InvLotModel.h"
@protocol InvModel @end
@interface InvModel : JSONModel
@property (assign, nonatomic) int id;
@property (strong, nonatomic) NSString* itemid;
@property (strong, nonatomic) NSString* description;
@property (strong, nonatomic) NSDate* createdate;
@property (strong, nonatomic) NSString* createuser;
@property (assign, nonatomic) float lastcost;
@property (assign, nonatomic) BOOL monitorlevel;
@property (assign, nonatomic) int minlevel;
@property (assign, nonatomic) int maxlevel;
@property (strong, nonatomic) NSString* gtin;
@property (assign, nonatomic) float weight;
@property (strong, nonatomic) NSString* uom;
@property (strong, nonatomic) NSString* sizes;
@property (strong, nonatomic) NSString* variety;
@property (strong, nonatomic) NSString <Optional>* bag;
@property (strong, nonatomic) NSString* style;
@property (strong, nonatomic) NSString* box;
@property (strong, nonatomic) NSString* label;
@property (strong, nonatomic) NSString* commodity;
@property (strong, nonatomic) InvLotModel* LotDTO;
@end