Panoramio - 搜索一张图片API

时间:2014-01-10 09:37:51

标签: json api search panoramio

1 个答案:

答案 0 :(得分:0)

public class MapLocation
{
    public double lat { get; set; }
    public double lon { get; set; }
    public int panoramio_zoom { get; set; }
}

public class Photo
{
    public int height { get; set; }
    public double latitude { get; set; }
    public double longitude { get; set; }
    public int owner_id { get; set; }
    public string owner_name { get; set; }
    public string owner_url { get; set; }
    public string photo_file_url { get; set; }
    public int photo_id { get; set; }
    public string photo_title { get; set; }
    public string photo_url { get; set; }
    public string upload_date { get; set; }
    public int width { get; set; }
    public string place_id { get; set; }
}

public class RootObject
{
    public int count { get; set; }
    public bool has_more { get; set; }
    public MapLocation map_location { get; set; }
    public List<Photo> photos { get; set; }
}

var dataContractJsonSerializer = new DataContractJsonSerializer(typeof(RootObject));
RootObject readObject = (RootObject)dataContractJsonSerializer.ReadObject(memoryStream);

foreach (var item in readObject.photos)
{
    //item.photo_file_url
    //item.photo_id
    //item.photo_title
    //item.photo_url
    //item.upload_date

    // and etc.
}

阅读此帖Parsing JSON