2017-04-25 11 views
-3

iOSアプリケーションでこのJSONレスポンスを解析しようとしています。しかし残念ながら私はそれをすることができません。私はできることすべてを試みたが、まだ運がない。これで私を助けてもらえますか?iOSアプリケーションでネストされたJSONレスポンスを解析する方法

"d_wtime" =「{ '日曜日':{ 'fromhours': '12'、 'fromtype': 'PM'、 'tohours': '12'、 'totype': 'AM'、」 'fromhours2': '12'、 'fromtype2': 'PM'、 'tohours2':'12 '、' totype2 ':' AM '}、' Monday ':{' fromhours ':' 12 '、' fromtype ':' from32 '、' tohours2 ':' 12 '、' totype2 ':' AM '、' fromhours2 ':' 12 '、' fromtype2 ':' PM '、' tohours ' 「from」、「from」、「from」、「from」、「from」、「from」、「from」、「from」、「from」、「from」、 'fromhours': '12'、 'fromtype': 'PM'、 'tohours': '12'、 'tohours2': '12'、 'totype2': 'AM' 、 'TOYours2': '12'、 'totype2': 'AM'}、 'Thursday':{'fromhours'、 'totype': 'AM'、 'fromhours2': '12'、 'fromtype2': 'PM' '12 '、' fromtype2 ':' PM '、' tohours2 ':'12'、 'fromtype'、 'tohours': '12'、 'totype': 'AM'、 'fromhours2' 12 '、' totype2 ':' AM '}、'金曜日 ':{' fromhours ':' 12 '、' fromtype ':' PM '、' tohours ':' 12 '、' totype ':' AM ' fromhours2 ':' 12 '、' fromtype2 ':' PM ' 'fromhours': '12'、 'fromtype': 'PM'、 'tohours': '12'、 'totype'、 'tohours2': '12'、 'totype2': 'AM' : 'AM'、 'fromhours2': '12'、 'fromtype2': 'AM'、 'tohours2': '12'、 'totype2': 'AM'}} ";

+0

を持つことができますJSONは醜いであることを考える必要がありますあなたが持っている問題。 – rmaddy

+0

私は上に示したように応答しています。タグはほとんどありません。アプリに表示する必要がある出力は、日曜 - 午後12時から午後12時までです。 月曜日から午後12時から午後12時まで 火曜日から午後12時から午後12時まで 水曜日から午後12時から午後12時まで 木曜日から午後12時12 AM 金曜日 - 午後12時から午前12時 土曜日 - 午後12時から午後12時日曜日 - 午後12時から午前12時 –

+0

上記の応答のうち4つのタグを使用する必要があります。 "fromhours"、 "fromtype" 、 "tohours"、 "totype" –

答えて

0

あなたの質問は、このJSONを解析し、明確に何を説明するために、あなたの試みで更新

let JSONArray = response["d_wtime"] as! [[String:[String: String]]] 
for JSONDic in JSONArray { 
    let sundayJSON = JSONDic["Sunday"] as! [String: String] 
    let fromHours = sundayJSON["fromhours"] as! String 
    . 
    . 
    . 
} 

ようなものになるが、私は、あなたがよりダイナミックかつ汎用的なJSON

+0

ありがとうございました。私は実際にthiaに取り組む必要があります。私はあなたのコメントから、レスポンスが醜いことを認識しました。私はチームメンバーが素敵になるようにチェックし、さらに進めていく予定です。 –

関連する問題