Google Books API数据是否为PHP数组?

时间:2012-04-26 14:36:53

标签: php

我从谷歌获得以下回复:

{
 "kind": "books#volumes",
 "totalItems": 1,
 "items": [
  {
   "kind": "books#volume",
   "id": "t9S82uKGp8IC",
   "etag": "rn9INXAtx88",
   "selfLink": "https://www.googleapis.com/books/v1/volumes/t9S82uKGp8IC",
   "volumeInfo": {
    "title": "Classic Swedish Interiors",
    "authors": [
     "Lars Sjöberg",
     "Ingalill Snitt"
    ],
    "publisher": "Frances Lincoln Ltd",
    "publishedDate": "2010-09-07",
    "description": "Lars Sjöberg has made it his life's work to understand and         preserve the Swedish manor houses of the 17th and 18th centuries. Here, exquisitely photographed by Ingalill Snitt, are the eight houses (and one church) that he has acquired over more than 40 years. The book focuses on Sjöberg's first, most complex project: the manor of Regnaholm. Unoccupied for about 40 years when Sjöberg arrived in 1966, it allowed him to experiment with interior decoration and refurnishing, copying old furniture, reweaving, and reprinting old fabric patterns. His other projects include Ekensberg, a three-story Italianate villa near Lake Mälaren, built in 1788-90, and Salaholm in Västergötland with a garden laid out in the first half of the 17th century. Odenslunda, a small manor from the 1770s with a panelled exterior and a säteritak or manor-house roof, is his family home, while Sörby, a scaled-down early 17th-century manor house, was reproduced in its entirety for an exhibition in Stockholm. Full of insight and inspiration, this is a deeply personal summary of everything Lars Sjöberg has learned in his years of working and living with classic Swedish interiors.",
"industryIdentifiers": [
 {
  "type": "ISBN_10",
  "identifier": "0711230889"
 },
 {
  "type": "ISBN_13",
  "identifier": "9780711230880"
 }
],
"pageCount": 208,
"printType": "BOOK",
"categories": [
 "Architecture"
],
"contentVersion": "preview-1.0.0",
"imageLinks": {
 "smallThumbnail": "http://bks8.books.google.com/books?id=t9S82uKGp8IC&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api",
 "thumbnail": "http://bks8.books.google.com/books?id=t9S82uKGp8IC&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api"
},
"language": "en",
"previewLink": "http://books.google.com/books?id=t9S82uKGp8IC&printsec=frontcover&dq=isbn:9780711230880&cd=1&source=gbs_api",
"infoLink": "http://books.google.com/books?id=t9S82uKGp8IC&dq=isbn:9780711230880&source=gbs_api",
"canonicalVolumeLink": "http://books.google.com/books/about/Classic_Swedish_Interiors.html?id=t9S82uKGp8IC"
   },
   "saleInfo": {
    "country": "ZA",
    "saleability": "NOT_FOR_SALE",
    "isEbook": false
   },
   "accessInfo": {
    "country": "ZA",
    "viewability": "PARTIAL",
    "embeddable": true,
    "publicDomain": false,
    "textToSpeechPermission": "ALLOWED_FOR_ACCESSIBILITY",
    "epub": {
     "isAvailable": false
    },
    "pdf": {
         "isAvailable": true,
         "acsTokenLink": "http://books.google.com/books/download    /Classic_Swedish_Interiors-sample-pdf.acsm?id=t9S82uKGp8IC&format=pdf&output=acs4_fulfillment_token&dl_type=sample&source=gbs_api"
        },
        "webReaderLink": "http://books.google.com/books/reader?id=t9S82uKGp8IC&    printsec=frontcover&output=reader&source=gbs_api",
        "accessViewStatus": "SAMPLE"
       },
       "searchInfo": {
        "textSnippet": "Full of insight and inspiration, this is a deeply personal summary of everything Lars Sjöberg has learned in his years of working and living with classic Swedish interiors."
       }
      }
     ]
  1. 这种格式叫什么? (它不是XML或JSON?)
  2. 如何将此文本转换为PHP数组?

1 个答案:

答案 0 :(得分:4)

这是JSON。您可以使用json_decode()将其转换为PHP关联数组。

$books = json_decode($your_json_data, true);
print_r($books);