ios json 解析与 afnetworking
Posted
技术标签:
【中文标题】ios json 解析与 afnetworking【英文标题】:ios json parse with afnetworking 【发布时间】:2014-03-19 12:37:17 【问题描述】:嗨 :) 我在解析 json 数据时遇到带重音的单词问题 它是网络服务中的第一个,但我修复了它
<?php
header('Content-Type: text/json; charset=utf-8');
include('settings.php');
mysql_connect($host,$user,$password);
mysql_select_db($base);
mysql_query('SET CHARACTER SET utf8');
$req = "select * from patient";
$sql=mysql_query($req);
$nn=mysql_num_rows($sql);
$items = array("items" => NULL);
while ($data=mysql_fetch_array($sql))
$items["items"][] = array(
"id_patient" => $data['id_patient'],
"nom" => $data['nom'],
"prenom" => $data['prenom'],
"Sexe" => $data['Sexe'],
"date_de_naissance" => $data['date_de_naissance'],
"lieu_de_naissance" => $data['lieu_de_naissance'],
"adresse" =>$data['adresse'],
"latitude" => $data['latitude'],
"longitude" => $data['longitude'],
"telephone" => $data['telephone'],
"email" => $data['email'],
"situation_familiale" => $data['situation_familiale'],
"profession" => $data['profession'],
"numero_securite_sociale" => $data['numero_securite_sociale'],
"taille" => $data['taille'],
"poids" => $data['poids'],
"situation_familiale" => $data['situation_familiale'],
"groupe_sanguin" => $data['groupe_sanguin'],
"allergies" =>$data['allergies'],
"antecedents_chirurgicaux" => $data['antecedents_chirurgicaux'],
"antecedents_medicaux" => $data['antecedents_medicaux'],
"antecedents_familiaux" => $data['antecedents_familiaux'],
);
echo json_encode($items,JSON_UNESCAPED_UNICODE);
?>
in the server its good im getting it fine
"allergies":poussiére
但是当我用 afnetworking 解析它时,我会过敏 = "poussi\U00e9re";
谁能帮帮我:) thx
【问题讨论】:
仅当您记录内容时,还是当您将其显示在屏幕上时? 它只是在日志中我还没有尝试显示它 试试显示应该没问题 你能添加你的api请求吗 【参考方案1】:在你的请求方法中添加这个
[AFJSONRequestOperation addAcceptableContentTypes:
[NSSet setWithObject:@"text/json"]];
【讨论】:
以上是关于ios json 解析与 afnetworking的主要内容,如果未能解决你的问题,请参考以下文章
IOS AFNetworking的使用与YYModel解析JSON数据
在 iOS 5 中使用 AFNetworking 解析 JSON