2013-04-18 5 views
-3

comment analyser la réponse de savon dans JSON Tableau chaîne de réponse de savon: -comment analyser la réponse du savon tableau JSON dans iOS

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, \" nom_réception \ ": \" cantine 21 \ ", \" adresse_restante \ ": \" 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]; 
+0

Avec un analyseur JSON, dont il existe plusieurs. Sauf que ce qui précède n'est pas tout à fait légal JSON. Le seul JSON légal est la partie après 'tempuri.org ^>'. –

+0

Wasap le point de SOAP pour ne pas avoir à s'inquiéter de la sérialisation des valeurs transportées? Peut-être que vous souhaitez utiliser autre chose pour votre application. – ToBe

+0

Tout analyseur JSON – Rakesh

Répondre

1

Utilisez NSJSONSerialization

. 210

Selon les documents Vous utilisez la classe NSJSONSerialization pour convertir des objets JSON en objets Foundation et convertir des objets Foundation en JSON.

[{\ "rest_id \": 1, \ "nom_réception \": \ "cantine 21 \", \ "adresse_restante \": \ "janakpuri \", \ "clientid \": 1, \ "rest_lat \ ": \" 28.619713 \ ", \" rest_long \ ": \" 77.088404}] "

Cette partie est json et elle peut être analysée, alors faites le code pour obtenir cette partie dans une chaîne et effectuez l'analyse

+0

J'ai utilisé NSJSONSerialization mais le résultat est nul. NSArray * jsonArray = [NSJSONSerialization JSONObjectWithData: options webData: erreur NSJSONReadingAllowFragments: &e]; – Rakesh

+0

@Rakesh - Parce que ce n'est pas JSON. –

+0

comment analyser cette chaîne toute idée s'il vous plaît aider. – Rakesh

Questions connexes