iphone,SBJsonWriter ..转换对象
|
我想将json对象发布到请求。但是JSONWriter似乎并没有转换我的对象,也不知道我在做什么错...
这是我的转换代码。
customer = [[Customer alloc] init];
Address *tempAddr = [[Address alloc] init];
tempAddr.Line1=strAddr1 ;
tempAddr.Zip =strPost;
tempAddr.City =strStreet;
[customer setInvoiceAddress:tempAddr];
customer.FirstName=strFirstName;
customer.LastName=strLastName;
customer.CellPhone=strCellPhone;
customer.Phone=strPhone;
customer.Email=strEmail;
SBJsonWriter *writer = [SBJsonWriter alloc];
NSString *jsonConvertedObj = [writer stringWithObject:customer];
NSLog(@\"the json converted object ... %@\", jsonConvertedObj);
请帮忙。我不知道上面的代码有什么问题。
没有找到相关结果
已邀请:
2 个回复
才改隘瘁
扭湘阀柿蹄
这是一个演示如何使用它的简单代码:
输出
注意: 使用\'error \'可以让我弄清楚,如果您编写[NSDate 日期]而不是[[NSDate日期]描述],您将获得一个\“ JSON 不支持序列化 __NSTaggedDate \”错误。 注意float舍入错误... 1.2345变为1.2345000505447388