在这个应用程序中,有人为我构建了这个代码来解析一个 json 数组:
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/lending.php?category_id=1",host_name ]]];
[request setRequestMethod:@"GET"];
它工作正常,现在,我需要的是插入这个数组而不是lendig.php,这实际上是json数组的输出:
[{"name":"Ekspres Kredi","category_id":"1","id":"2"},{"name":"Kredi p\u00ebr Pushime ","category_id":"1","id":"4"},{"name":" Kredi Konsumuese ","category_id":"1","id":"5"},{"name":"Auto Kredi ","category_id":"1","id":"6"}]
我怎样才能插入呢?
它应该是这样的:
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"[{"name":"Ekspres Kredi","category_id":"1","id":"2"},{"name":"Kredi p\u00ebr Pushime ","category_id":"1","id":"4"},{"name":" Kredi Konsumuese ","category_id":"1","id":"5"},{"name":"Auto Kredi ","category_id":"1","id":"6"}]",host_name ]]];
[request setRequestMethod:@"GET"];