プログラミング初心者です。
GoogleブックスAPIを使ってISBNコードから書籍を検索するアプリを制作しているのですが、プラウザで確認したときは日本語で書かれていた文字列が、Xcodeのコンソール上では文字と数字の羅列に変換さていました。
Swift
1 2 let url: URL = URL(string: "https://www.googleapis.com/books/v1/volumes?q=4022591323")! 3 let task: URLSessionTask = URLSession.shared.dataTask(with: url, completionHandler: { data, response, error in 4 do { 5 let json = try JSONSerialization.jsonObject(with: data!, options: JSONSerialization.ReadingOptions.allowFragments) as! [String: Any] 6 print(json) 7 print("count (Int(json.count))") 8 } 9 catch{ 10 print(error) 11 } 12 }) 13 task.resume() 14
コンソールに表示されたのは
["kind": books#volumes, "items": <__NSArrayI 0x280802760>( { accessInfo = { accessViewStatus = NONE; country = JP; embeddable = 0; epub = { isAvailable = 0; }; pdf = { isAvailable = 0; }; publicDomain = 0; quoteSharingAllowed = 0; textToSpeechPermission = ALLOWED; viewability = "NO_PAGES"; webReaderLink = "http://play.google.com/books/reader?id=7Ja-SgAACAAJ&hl=&printsec=frontcover&source=gbs_api"; }; etag = hsFzUDJcceY; id = "7Ja-SgAACAAJ"; kind = "books#volume"; saleInfo = { country = JP; isEbook = 0; saleability = "NOT_FOR_SALE"; }; searchInfo = { textSnippet = "\U7f8e\U3068\U3044\U3046\U306e\U306f\U3001\U3044\U308d\U3044\U308d\U306e\U4e16\U754c\U3067\U3001\U672c\U5f53\U306e\U81ea\U5206\U3001\U3042\U308b\U3079\U304d\U81ea\U5206\U3001\U6df1\U3044\U6df1\U3044\U4e16\U754c\U306b\U304b\U304f\U308c\U3066\U3044\U308b\U81ea\U5206\U306b\U3001\U3081\U3050\U308a\U9022\U3046\U3053\U3068\U2015\U82b8\U8853\U3092\U901a\U3058\U3066\U73fe\U4ee3\U3068\U3044\U3046\U6642\U4ee3\U306e\U904b\U547d\U3092\U4e88\U8a00\U3059\U308b\U8a66\U307f\U3002\U8c4a\U304b ..."; }; selfLink = "https://www.googleapis.com/books/v1/volumes/7Ja-SgAACAAJ"; volumeInfo = { allowAnonLogging = 0; authors = ( "\U4e2d\U4e95\U6b63\U4e00" ); canonicalVolumeLink = "https://books.google.com/books/about/%E7%BE%8E%E5%AD%A6%E5%85%A5%E9%96%80.html?hl=&id=7Ja-SgAACAAJ"; categories = ( Aesthetics ); contentVersion = "preview-1.0.0"; description = "\U7f8e\U3068\U3044\U3046\U306e\U306f\U3001\U3044\U308d\U3044\U308d\U306e\U4e16\U754c\U3067\U3001\U672c\U5f53\U306e\U81ea\U5206\U3001\U3042\U308b\U3079\U304d\U81ea\U5206\U3001\U6df1\U3044\U6df1\U3044\U4e16\U754c\U306b\U304b\U304f\U308c\U3066\U3044\U308b\U81ea\U5206\U306b\U3001\U3081\U3050\U308a\U9022\U3046\U3053\U3068\U2015\U82b8\U8853\U3092\U901a\U3058\U3066\U73fe\U4ee3\U3068\U3044\U3046\U6642\U4ee3\U306e\U904b\U547d\U3092\U4e88\U8a00\U3059\U308b\U8a66\U307f\U3002\U8c4a\U304b\U3055\U3068\U8edf\U3089\U304b\U3055\U3092\U305d\U306a\U3048\U305f\U3001\U5f37\U9771\U306a\U82b8\U8853\U8ad6\U3002"; imageLinks = { smallThumbnail = "http://books.google.com/books/content?id=7Ja-SgAACAAJ&printsec=frontcover&img=1&zoom=5&source=gbs_api"; thumbnail = "http://books.google.com/books/content?id=7Ja-SgAACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api"; }; industryIdentifiers = ( { identifier = 4122053323; type = "ISBN_10"; }, { identifier = 9784122053328; type = "ISBN_13"; } ); infoLink = "http://books.google.co.jp/books?id=7Ja-SgAACAAJ&dq=4022591323&hl=&source=gbs_api"; language = ja; maturityRating = "NOT_MATURE"; pageCount = 180; previewLink = "http://books.google.co.jp/books?id=7Ja-SgAACAAJ&dq=4022591323&hl=&cd=1&source=gbs_api"; printType = BOOK; publishedDate = "2010-06"; readingModes = { image = 0; text = 0; }; title = "\U7f8e\U5b66\U5165\U9580"; }; },
このように、できれば日本語で見れたほうがいいのですが、この英数字文字列になったJSONを日本語に直す方法にはどのようにすれば良いでしょうか。
ご教示いただけたら幸いです。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/12/20 04:43