首页 文章

如何在iOS中解析JSON数组中的soap响应

提问于
浏览
-3

如何在JSON Array soap响应字符串中解析soap响应: -

NSString * string = @“http://schemas.xmlsoap.org/soap/envelope/ \”xmlns:xsi = \“http://www.w3.org/2001/XMLSchema-instance \”xmlns:xsd = \ “http://www.w3.org/2001/XMLSchema \”> http://tempuri.org/ \“> [{\”rest_id \“:1,\”rest_name \“:\”食堂21“ ,“rest_address \”:\“janakpuri \”,\“clientid \”:1,\“rest_lat \”:\“28.619713 \”,\“rest_long \”:\“77.088404}]”;

NSData *webData = [string dataUsingEncoding:NSASCIIStringEncoding];
NSError *e = nil;
NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData: webData options: NSJSONReadingAllowFragments error: &e];

1 回答

  • 1

    使用NSJSONSerialization .

    根据文档,您可以使用NSJSONSerialization类将JSON转换为Foundation对象,并将Foundation对象转换为JSON .

    [{\“rest_id \”:1,\“rest_name \”:\“食堂21 \”,\“rest_address \”:\“janakpuri \”,\“clientid \”:1,\“rest_lat \”:\ “28.619713 \”,\“rest_long \”:\“77.088404}]”

    这部分是json,它可以被解析,因此使代码将此部分转换为字符串并进行解析

相关问题