目前我有一個字符串,我想POST到一個URL。JSON數據NULL特殊字符「&」
除非遇到像「&」這樣的特殊字符,否則它工作得很好。它會發布其後的其他數據。例如,我有品牌的文本字符串「張&紅」,通過選擇模型值取決於品牌文本正在解析URL作爲
post=[NSString stringWithFormat:@"http://moneytree.com.au/rest-webservice/rest/&Brand=%@",StrbrandSelect1];
NSURL *url;
url = [NSURL URLWithString:[post
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *RequestSubject=[[NSMutableURLRequest alloc]init];
[RequestSubject setURL:url];
[RequestSubject setHTTPMethod:@"POST"];
NSLog(@"RequestSubject %@",RequestSubject);
Typedata1 = [NSURLConnection sendSynchronousRequest:RequestSubject
returningResponse:Nil error:Nil];
if (RequestSubject)
{
NSDictionary *Dictjson = [NSJSONSerialization
JSONObjectWithData:Typedata1
options:kNilOptions
error:nil];
NSLog(@"The JSON outPut is:%@",Dictjson);
NSLog(@"The Array Count is: %d",[Dictjson count]);
但陣列數爲:0
選擇數據取決於品牌「Chang & hong」
我需要的輸出數據取決於品牌字符串模型文本 - 「等離子」和「LCD」。
請幫幫我。
您是否嘗試在瀏覽器中手動轉到該地址並查看彈出的內容?網絡服務是否屬於你(你是否編碼?) –
這個鏈接導致我無處可去,我想你忘了替換%@ –
@YoavSchwartz:你可以在代碼中編輯。謝謝。 –