如何从json feed中读取数据 - Windows Phone

时间:2012-05-06 19:53:52

标签: c# json windows-phone-7

我一直在研究这个问题,我试图从Json获取公司ID和名称,但我得到:NullExceptionReference(来自:DataContractJsonSerializer)。

这是我的代码:

 public partial class MainPage : PhoneApplicationPage
{
    // Constructor
    public MainPage()
    {
        InitializeComponent();
        myButton.Click += new RoutedEventHandler(myButton_Click);
    }
    void myButton_Click(object sender, RoutedEventArgs e)
    {

        try
        {
            WebClient webClient = new WebClient();
            Uri uri = new Uri("http://sherutnetphpapi.cloudapp.net/?method=Company");
            webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(webClient_OpenReadCompleted);
            try
            {
                webClient.OpenReadAsync(uri);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
    void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
    {
        MessageBox.Show("OpenRead Handler");

      //  OpenWriteCompletedEventArgs temp = (OpenWriteCompletedEventArgs)e;
        DataContractJsonSerializer serializer = null;
        try
        {
            serializer = new DataContractJsonSerializer(typeof(ObservableCollection<Brand>));
            ObservableCollection<Brand> Brands = serializer.ReadObject(e.Result) as ObservableCollection<Brand>;
            foreach (Brand b in Brands)
            {
                int id = b.CompanyID;
                string name = b.Name;
                listBrands.Items.Add(id + "             " + name);

            }

        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }

    }
}

这是Brand类(代表公司):

    public class Brand
{/*
    public string BrandName { get; set; }
    public int BrandId { get; set; }
       */
    public string CompanyGUID { get; set; }
    public int CompanyID { get; set; }
    public int CategoryID { get; set; }
    public string Name { get; set; }
    public string NameEn { get; set; }
    public string Description { get; set; }
    public string WebSite { get; set; }
    public string Num { get; set; }
    public string Num2 { get; set; }
    public string FaxNum { get; set; }
    public string Email { get; set; }
    public string Address { get; set; }
    public string Twitter { get; set; }
    public string Facebook { get; set; }
    public string GooglePlus { get; set; }
    public string App_iOS{ get; set; }
    public string App_Android { get; set; }
    public string App_WinPhone { get; set; }
    public string App_BlackBerry { get; set; }
    public string Blog { get; set; }
    public string Chat { get; set; }
    public string Icon { get; set; }
    public string SearchTags { get; set; }
    public int Rating { get; set; }
    public int Public { get; set; }
    public int ToShow { get; set; }
    public int Revision { get; set; }

}

} 这是我试图阅读的Json:

{"schema":{"CompanyGUID":"TEXT","CompanyID":"INTEGER","CategoryID":"INTEGER","Name":"TEXT","NameEn":"TEXT","Description":"TEXT","WebSite":"TEXT","Num":"TEXT","Num2":"TEXT","FaxNum":"TEXT","Email":"TEXT","Address":"TEXT","Twitter":"TEXT","Facebook":"TEXT","GooglePlus":"TEXT","App_iOS":"TEXT","App_Android":"TEXT","App_WinPhone":"TEXT","App_BlackBerry":"TEXT","Blog":"TEXT","Chat":"TEXT","Icon":"TEXT","SearchTags":"TEXT","Rating":"REAL","Public":"INTEGER","ToShow":"INTEGER","Revision":"INTEGER"},"data":[{"CompanyGUID":"E6D72217-B58E-4618-B8C9-003CD7835AAE","CompanyID":104,"CategoryID":2,"Name":"orange","NameEn":"Orange","Description":"\u05e4\u05e8\u05d8\u05e0\u05e8 \u05ea\u05e7\u05e9\u05d5\u05e8\u05ea","WebSite":"www.orange.co.il","Num":"*054","Num2":"03-9054054","FaxNum":"074-7077858","Email":"forum@orange.co.il","Address":"\u05e8\u05d7\u05d5\u05d1 \u05e2\u05de\u05dc 8, \u05e4\u05d0\u05e8\u05e7 \u05ea\u05e2\u05e9\u05d9\u05d5\u05ea \u05d0\u05e4\u05e7, \u05ea\"\u05d3 435, \u05e8\u05d0\u05e9 \u05d4\u05e2\u05d9\u05df 48103","Twitter":"orangeIL","Facebook":"facebook.com\/ILorange","GooglePlus":"","App_iOS":"http:\/\/itunes.apple.com\/il\/app\/my-orange\/id405509584","App_Android":"https:\/\/play.google.com\/store\/apps\/details?id=il.co.orange.app.myorange","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Orange.png","SearchTags":null,"Rating":3,"Public":1,"ToShow":1,"Revision":7},{"CompanyGUID":"BB00F6EF-3F83-4C5A-BEF4-0A6EDF69E02F","CompanyID":186,"CategoryID":7,"Name":"\u05e9\u05dc\u05de\u05d4 sixt","NameEn":"Shlomo","Description":"","WebSite":"www.shlomo.co.il","Num":"*6880","Num2":"1700-501-502","FaxNum":"","Email":"","Address":"\u05e8\u05d7\u05d5\u05d1 \u05d4\u05d9\u05e6\u05d9\u05e8\u05d4 22, \u05e7\u05e8\u05d9\u05ea \u05d0\u05e8\u05d9\u05d4 \u05e4\u05ea\u05d7 \u05ea\u05e7\u05d5\u05d5\u05d4 49512","Twitter":"","Facebook":"","GooglePlus":"","App_iOS":"http:\/\/itunes.apple.com\/il\/app\/shlomo-sixt-slmh\/id364917805","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Shlomo.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":5},{"CompanyGUID":"8137BAEE-A40E-49BA-AD67-0C460C0B3D91","CompanyID":194,"CategoryID":14,"Name":"\u05e2\u05d9\u05e8\u05d9\u05d9\u05ea \u05d2\u05d1\u05e2\u05ea\u05d9\u05d9\u05dd","NameEn":"Givataym","Description":"\u05e2\u05d9\u05e8\u05d9\u05d9\u05d4","WebSite":"www.givatayim.muni.il","Num":"03-5717222","Num2":"","FaxNum":"03-7313962","Email":"PniyotG@givatayim.muni.il","Address":"\u05e9\u05d9\u05e0\u05e7\u05d9\u05df ,6 \u05d2\u05d1\u05e2\u05ea\u05d9\u05d9\u05dd, \u05de\u05d9\u05e7\u05d5\u05d3 53299","Twitter":"","Facebook":"","GooglePlus":"","App_iOS":"","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Givataym.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":5},{"CompanyGUID":"4F4184AE-9DF3-43B1-AA04-0DC6014D8DF4","CompanyID":193,"CategoryID":14,"Name":"\u05e2\u05d9\u05e8\u05d9\u05d9\u05ea \u05e0\u05ea\u05e0\u05d9\u05d4","NameEn":"Netanya","Description":"","WebSite":"www.netanya.muni.il","Num":"09-8603126","Num2":"","FaxNum":"09-8608855","Email":"orna_p@netanya.muni.il","Address":"\u05d4\u05e6\u05d5\u05e8\u05df 6 \u05e0\u05ea\u05e0\u05d9\u05d4,  \u05e7\u05e8\u05d9\u05d9\u05ea \u05e1\u05e4\u05d9\u05e8, \u05de\u05d9\u05e7\u05d5\u05d3  42506","Twitter":"","Facebook":"","GooglePlus":"","App_iOS":"","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Netanya.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":5},{"CompanyGUID":"438A9A32-8F4D-437D-8758-0F775335FBA8","CompanyID":228,"CategoryID":18,"Name":"\u05d8\u05d9\u05d1 \u05d8\u05e2\u05dd","NameEn":"Tivtaam","Description":"","WebSite":"www.tivtaam.co.il","Num":"1-700-709-111","Num2":"04-6179485","FaxNum":"04-6179051","Email":"","Address":"\u05e6\u05d1\u05d9 \u05d4\u05e0\u05d7\u05dc   1  \u05e4\u05d0\u05e8\u05e7 \u05ea\u05e2\u05e9\u05d9\u05d5\u05ea \u05e2\u05de\u05e7 \u05d7\u05e4\u05e8  38777\n","Twitter":"","Facebook":"facebook.com\/TivTaamIL","GooglePlus":"","App_iOS":"","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Tivtaam.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":5},{"CompanyGUID":"8B7C1308-4872-45E3-A43A-0FBF53C10421","CompanyID":161,"CategoryID":14,"Name":"\u05e2\u05d9\u05e8\u05d9\u05d9\u05ea \u05e8\u05d0\u05e9\u05d5\u05df \u05dc\u05e6\u05d9\u05d5\u05df","NameEn":"Rishon","Description":"","WebSite":"www.rishonlezion.muni.il","Num":"106","Num2":"03-9542799","FaxNum":"03-9542772","Email":"etil@rishonlezion.muni.il","Address":"\u05e8\u05d7' \u05d4\u05db\u05e8\u05de\u05dc 20, \u05e8\u05d0\u05e9\u05d5\u05df \u05dc\u05e6\u05d9\u05d5\u05df","Twitter":"","Facebook":"facebook.com\/pages\/rswn-lywn\/rswn-lywn\/30700351098","GooglePlus":"","App_iOS":"","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Rishon.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":5},{"CompanyGUID":"5D0CF5A0-DCF7-404F-8ED9-107478AC034C","CompanyID":138,"CategoryID":5,"Name":"\u05de\u05e0\u05d5\u05e8\u05d4-\u05de\u05d1\u05d8\u05d7\u05d9\u05dd","NameEn":"Menora","Description":"","WebSite":"www.menora.co.il","Num":"*2066","Num2":"03-7107777","FaxNum":"03-7107788","Email":"sherut@menora.co.il","Address":"\u05d1\u05d9\u05ea \u05de\u05e0\u05d5\u05e8\u05d4 \u05de\u05d1\u05d8\u05d7\u05d9\u05dd, \u05ea.\u05d3. 927, \u05ea\"\u05d0","Twitter":"","Facebook":"facebook.com\/profile.php?id=100000825403324","GooglePlus":"","App_iOS":"","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Menora.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":5},{"CompanyGUID":"0679A343-3590-4E62-9FA0-13E4B18C5A80","CompanyID":224,"CategoryID":18,"Name":"\u05e9\u05d5\u05e4\u05e8\u05e1\u05dc","NameEn":"Shufersal","Description":"","WebSite":"www.shufersal.co.il","Num":"1800-68-68-68","Num2":"03-9481515","FaxNum":"03-9480906","Email":"","Address":"\u05e9\u05de\u05d5\u05d8\u05e7\u05d9\u05df   30  \u05e8\u05d0\u05e9\u05d5\u05df \u05dc\u05e6\u05d9\u05d5\u05df  75363","Twitter":"","Facebook":"facebook.com\/shufersal","GooglePlus":"","App_iOS":"http:\/\/itunes.apple.com\/il\/app\/swprsl\/id411873937","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Shufersal.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":5},{"CompanyGUID":"6E2F633A-BD18-44F9-8D84-14A136FC3C63","CompanyID":153,"CategoryID":10,"Name":"\u05d0\u05e1\u05dd","NameEn":"Osem","Description":"","WebSite":"www.osem.co.il","Num":"1-700-70-76-76","Num2":"","FaxNum":"","Email":"","Address":"\u05e7\u05e8\u05d9\u05ea \u05d0\u05e1\u05dd, \u05ea.\u05d3. 934 \u05e9\u05d5\u05d4\u05dd 60850","Twitter":"","Facebook":"facebook.com\/pages\/Osem-sm\/45502578020","GooglePlus":"","App_iOS":"","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Osem.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":5},{"CompanyGUID":"66B7C3CB-6FAB-481B-AC04-194E2A48BF9F","CompanyID":109,"CategoryID":2,"Name":"\u05d1\u05d6\u05e7 \u05d1\u05d9\u05e0\u05dc\u05d0\u05d5\u05de\u05d9","NameEn":"BezeqInt","Description":"","WebSite":"www.bezeqint.net","Num":"*3014","Num2":"076-5014014","FaxNum":"03-9285038","Email":"cservice@bezeqint.net","Address":"\u05d4\u05e9\u05d7\u05dd 40, \u05e4\u05ea\u05d7 \u05ea\u05e7\u05d5\u05d5\u05d4  49170","Twitter":"BezeqBenleumi","Facebook":"facebook.com\/BezeqBenleumi","GooglePlus":"","App_iOS":"","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"http:\/\/212.179.95.132\/chat\/livehelp.php","Icon":"BezeqInt.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":6},{"CompanyGUID":"7F4703BE-9FC9-4ED3-B439-1AD473A94AB0","CompanyID":149,"CategoryID":10,"Name":"\u05de\u05d9 \u05e2\u05d3\u05df","NameEn":"MeyEden","Description":"","WebSite":"www.meyeden.co.il","Num":"*5335","Num2":"1-700-70-2002","FaxNum":"03-5781486","Email":"","Address":"\u05d4\u05dc\u05d7\"\u05d9 19 \u05d1\u05e0\u05d9 \u05d1\u05e8\u05e7 51200","Twitter":"Mei_Eden","Facebook":"facebook.com\/pages\/my-dn\/135950196419799","GooglePlus":"","App_iOS":"","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"MeyEden.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":6},{"CompanyGUID":"A2EEDA0D-9AF1-468A-A6F2-1BF3CF1524AE","CompanyID":129,"CategoryID":9,"Name":"\u05de\u05e9\u05e8\u05d3 \u05d4\u05e4\u05e0\u05d9\u05dd","NameEn":"Moin","Description":"","WebSite":"www.moin.gov.il","Num":"*3450","Num2":"1-222-3450","FaxNum":"02-6469442","Email":"info@moin.gov.il","Address":"\u05de\u05d9\u05e0\u05d4\u05dc \u05d4\u05d0\u05d5\u05db\u05dc\u05d5\u05e1\u05d9\u05df, \u05e8\u05d7', \u05d4\u05dc\u05dc 24 \u05d9\u05e8\u05d5\u05e9\u05dc\u05d9\u05dd 91023","Twitter":"pnim_gov_il","Facebook":"","GooglePlus":"","App_iOS":"","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Moin.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":7},{"CompanyGUID":"9A65C271-B55C-4908-B5AF-1D66C5769BCF","CompanyID":205,"CategoryID":14,"Name":"\u05de\u05d5\u05e2\u05e6\u05d4 \u05d0\u05d6\u05d5\u05e8\u05d9\u05ea \u05e2\u05de\u05e7 \u05d9\u05d6\u05e8\u05e2\u05d0\u05dc","NameEn":"EmekIsrael","Description":"","WebSite":"www.emekyizrael.org.il","Num":"04-6520111","Num2":"","FaxNum":"04-6520085","Email":"moked@emekyizrael.org.il","Address":"\u05de.\u05d0 \u05e2\u05de\u05e7 \u05d9\u05d6\u05e8\u05d0\u05dc \u05ea.\u05d3 90000 \u05e2\u05e4\u05d5\u05dc\u05d4","Twitter":"","Facebook":"","GooglePlus":"","App_iOS":"","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"EmekIsrael.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":5},{"CompanyGUID":"B322B212-AB2F-4F5A-BDE4-22EDAE1A55A5","CompanyID":158,"CategoryID":14,"Name":"\u05e2\u05d9\u05e8\u05d9\u05d9\u05ea \u05d9\u05e8\u05d5\u05e9\u05dc\u05d9\u05dd","NameEn":"Jerusalem","Description":"","WebSite":"www.jerusalem.muni.il","Num":"106","Num2":"02-5314600","FaxNum":"02-6525544","Email":"moked@jerusalem.muni.il","Address":"\u05db\u05db\u05e8 \u05e1\u05e4\u05e8\u05d0 1, \u05d9\u05e8\u05d5\u05e9\u05dc\u05d9\u05dd","Twitter":"","Facebook":"","GooglePlus":"","App_iOS":"","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"http:\/\/blog.jerusalem.muni.il\/","Chat":"","Icon":"Jerusalem.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":5},{"CompanyGUID":"C6550E78-4D7E-4FE0-974F-230C2DFB2091","CompanyID":191,"CategoryID":2,"Name":"\u05d0\u05d9\u05e0\u05d8\u05e8\u05e0\u05d8 \u05e8\u05d9\u05de\u05d5\u05df","NameEn":"Rimon","Description":"","WebSite":"www.neto.net.il","Num":"*8900","Num2":"073-231-7000","FaxNum":"057-7961386","Email":"contactus@neto.net.il","Address":"\u05e8\u05d7\u05d5\u05d1 \u05e8\u05d7\u05d1\u05e2\u05dd \u05d6\u05d0\u05d1\u05d9 2,  \u05d2\u05d1\u05e2\u05ea \u05e9\u05de\u05d5\u05d0\u05dc","Twitter":"","Facebook":"facebook.com\/internetrimon","GooglePlus":"","App_iOS":"","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Rimon.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":5},{"CompanyGUID":"F2B08E21-7FA3-48CE-A5ED-234DAAB249F0","CompanyID":148,"CategoryID":13,"Name":"\u05dc\u05e0\u05d5\u05d1\u05d5 \u05d9\u05d1\u05de","NameEn":"Lenovo","Description":"","WebSite":"www.ibm.com\/support\/il\/he","Num":"*6557","Num2":"03-9142800","FaxNum":"03-9188211","Email":"6557@il.ibm.com","Address":"\u05d3\u05e8\u05da \u05d0\u05dd \u05d4\u05de\u05d5\u05e9\u05d1\u05d5\u05ea 94, \u05e7\u05e8\u05d9\u05ea \u05d0\u05e8\u05d9\u05d4, \u05e4\u05ea\u05d7 \u05ea\u05e7\u05d5\u05d5\u05d4, 49527","Twitter":"IBM_Israel","Facebook":"facebook.com\/IBMIL?ref=ts","GooglePlus":"","App_iOS":"","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Lenovo.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":6},{"CompanyGUID":"FA12B2FD-05C8-481A-BC3C-23679C1301E5","CompanyID":162,"CategoryID":6,"Name":"\u05d3\u05df","NameEn":"Dan","Description":"\u05d7\u05d9\u05d5\u05d2 \u05d1\u05db\u05d5\u05db\u05d1\u05d9\u05ea \u05de\u05d4\u05e0\u05d9\u05d9\u05d3 \u05d1\u05dc\u05d1\u05d3","WebSite":"www.dan.co.il","Num":"*3456","Num2":"03-6394444","FaxNum":"03-6933466","Email":"information@dan.co.il","Address":"\u05ea.\u05d3. 33038, \u05ea\"\u05d0 \u05de\u05d9\u05e7\u05d5\u05d3 64928","Twitter":"","Facebook":"","GooglePlus":"","App_iOS":"","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Dan.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":5},{"CompanyGUID":"7DF48BD1-8889-41A1-97F3-244C86F3CA91","CompanyID":159,"CategoryID":14,"Name":"\u05e2\u05d9\u05e8\u05d9\u05d9\u05ea \u05d1\u05d0\u05e8-\u05e9\u05d1\u05e2","NameEn":"Beer7","Description":"","WebSite":"www.beer-sheva.muni.il","Num":"106","Num2":"08-6463777","FaxNum":"08-6281911","Email":"p-moked@br7.org.il","Address":"\u05db\u05db\u05e8 \u05de\u05e0\u05d7\u05dd \u05d1\u05d2\u05d9\u05df   1  \u05d1\u05d0\u05e8 \u05e9\u05d1\u05e2  84891","Twitter":"","Facebook":"","GooglePlus":"","App_iOS":"","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Beer7.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":5},{"CompanyGUID":"29D46483-5068-4703-9D50-26DC852CCB98","CompanyID":139,"CategoryID":5,"Name":"AIG","NameEn":"Aig","Description":"","WebSite":"www.aig.co.il","Num":"1-800-400-400","Num2":"03-9272472","FaxNum":"03-9272424","Email":"aig.israel@aig.com","Address":"\u05e8\u05d7' \u05d4\u05e1\u05d9\u05d1\u05d9\u05dd 25, \u05e7\u05e8\u05d9\u05d9\u05ea \u05de\u05d8\u05dc\u05d5\u05df, \u05e4\u05ea\u05d7 \u05ea\u05e7\u05d5\u05d5\u05d4. \u05ea.\u05d3 535. \u05de\u05d9\u05e7\u05d5\u05d3 49100","Twitter":"AIG_Latestnews","Facebook":"facebook.com\/pages\/AIG\/55720723001","GooglePlus":"","App_iOS":"","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Aig.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":7},{"CompanyGUID":"DCD4DEEE-31D4-404A-88B1-27E176AE7D7C","CompanyID":220,"CategoryID":17,"Name":"\u05d4\u05d8\u05db\u05e0\u05d9\u05d5\u05df","NameEn":"Technion","Description":"","WebSite":"www.technion.ac.il","Num":"04-8292529","Num2":"04-8292111","FaxNum":"04-8295830","Email":"mina@tex.technion.ac.il","Address":"\u05e7\u05e8\u05d9\u05ea \u05d4\u05d8\u05db\u05e0\u05d9\u05d5\u05df, \u05d7\u05d9\u05e4\u05d4, 32000, \u05d9\u05e9\u05e8\u05d0\u05dc","Twitter":"TechnionLive","Facebook":"facebook.com\/Technion.Israel","GooglePlus":"","App_iOS":"","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Technion.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":6},{"CompanyGUID":"D02204BE-85A3-43C8-AF1C-2F5F1DB4708F","CompanyID":118,"CategoryID":8,"Name":"\u05dc\u05d0\u05d5\u05de\u05d9\u05ea","NameEn":"Leumit","Description":"","WebSite":"www.leumit.co.il","Num":"*507","Num2":"1-700-507-507","FaxNum":"03-6949614","Email":"publicappeals@leumit.co.il","Address":"\u05e9\u05e4\u05e8\u05d9\u05e0\u05e6\u05e7 23 \u05ea\u05dc \u05d0\u05d1\u05d9\u05d1 64738","Twitter":"","Facebook":"facebook.com\/leumit","GooglePlus":"","App_iOS":"","App_Android":"https:\/\/play.google.com\/store\/apps\/details?id=leumit.mobile","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Leumit.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":5},{"CompanyGUID":"9AD5EF41-1300-4D1A-8F40-33F78C766E01","CompanyID":218,"CategoryID":17,"Name":"\u05d4\u05d0\u05d5\u05e0\u05d9\u05d1\u05e8\u05e1\u05d9\u05d8\u05d4 \u05d4\u05e4\u05ea\u05d5\u05d7\u05d4","NameEn":"Openu","Description":"","WebSite":"www.openu.ac.il","Num":"*3500","Num2":"09-7782222","FaxNum":"","Email":"infodesk@openu.ac.il","Address":"\u05d3\u05e8\u05da \u05d4\u05d0\u05d5\u05e0\u05d9\u05d1\u05e8\u05e1\u05d9\u05d8\u05d4 1. \u05ea.\u05d3 808, \u05e8\u05e2\u05e0\u05e0\u05d4 43537","Twitter":"OpenU_Israel","Facebook":"facebook.com\/openuniversity","GooglePlus":"","App_iOS":"http:\/\/itunes.apple.com\/il\/app\/open-university-h-wnybrsyth\/id451404537","App_Android":"https:\/\/play.google.com\/store\/apps\/details?id=com.OpenUniversity","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Openu.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":7},{"CompanyGUID":"14A071CD-E266-4CC8-9894-34D0651BEC36","CompanyID":108,"CategoryID":2,"Name":"\u05e0\u05d8\u05d5\u05d5\u05d9\u05d6'\u05df 013","NameEn":"Netvision013","Description":"\u05e1\u05e4\u05e7\u05d9\u05ea \u05d0\u05d9\u05e0\u05d8\u05e8\u05e0\u05d8 \u05d5\u05e9\u05d9\u05d7\u05d5\u05ea \u05d1\u05d9\u05e0\u05dc\u05d0\u05d5\u05de\u05d9\u05d5\u05ea","WebSite":"www.013netvision.net.il","Num":"*3031","Num2":"04-8560660","FaxNum":"03-5201960","Email":"service@013netvision.co.il","Address":"\u05d4\u05de\u05dc\u05d0\u05db\u05d4 15 \u05e4\u05d0\u05e8\u05e7 \u05d0\u05e4\u05e7 \u05e8\u05d0\u05e9 \u05d4\u05e2\u05d9\u05df 48091","Twitter":"013_Netvision","Facebook":"facebook.com\/013netvision","GooglePlus":"","App_iOS":"","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Netvision013.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":7},{"CompanyGUID":"3342FC0D-BB7B-4752-8C57-371B52403DE2","CompanyID":156,"CategoryID":14,"Name":"\u05e2\u05d9\u05e8\u05d9\u05d9\u05ea \u05ea\u05dc \u05d0\u05d1\u05d9\u05d1","NameEn":"TelAviv","Description":"","WebSite":"www.tel-aviv.gov.il","Num":"03-5218666","Num2":"","FaxNum":"03-5216597","Email":"","Address":"\u05d0\u05d1\u05df \u05d2\u05d1\u05d9\u05e8\u05d5\u05dc 69 \u05ea\u05dc \u05d0\u05d1\u05d9\u05d1","Twitter":"","Facebook":"facebook.com\/pages\/Tel-Aviv-Yafo-Israel\/TEL-AVIV-tl-byb\/179016458408","GooglePlus":"","App_iOS":"","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"TelAviv.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":6},{"CompanyGUID":"05F0A2D8-8F11-41F4-A00A-389435D8566D","CompanyID":105,"CategoryID":2,"Name":"\u05e4\u05dc\u05d0\u05e4\u05d5\u05df","NameEn":"Pelephone","Description":"\u05d7\u05d9\u05d5\u05d2 \u05d1\u05db\u05d5\u05db\u05d1\u05d9\u05ea \u05dc\u05de\u05e0\u05d5\u05d9\u05d9\u05dd \u05d1\u05dc\u05d1\u05d3","WebSite":"www.pelephone.co.il","Num":"*166 ","Num2":"050-7077766","FaxNum":"050-7048004","Email":"Contact@pelephone.co.il","Address":"\u05d3\u05e8\u05da \u05d9\u05e6\u05d7\u05e7 \u05e8\u05d1\u05d9\u05df 33 \u05d2\u05d1\u05e2\u05ea\u05d9\u05d9\u05dd","Twitter":"Pelephone_il","Facebook":"facebook.com\/Pelephone","GooglePlus":"","App_iOS":"http:\/\/itunes.apple.com\/il\/app\/pl-pwn-on-line\/id465620580","App_Android":"https:\/\/play.google.com\/store\/apps\/details?id=com.pelephone","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"http:\/\/www.pelephone.co.il\/web\/3G\/Corporate\/CustomerService\/chat_live\/.aspx","Icon":"Pelephone.png","SearchTags":null,"Rating":3.2000000476837,"Public":1,"ToShow":1,"Revision":8},{"CompanyGUID":"CD18CE6F-FE06-4F8A-879A-3BF2DCDFD19F","CompanyID":123,"CategoryID":3,"Name":"\u05d4\u05d1\u05d9\u05e0\u05dc\u05d0\u05d5\u05de\u05d9","NameEn":"Fibi","Description":"","WebSite":"www.fibi.co.il","Num":"*3009","Num2":"03--5130031","FaxNum":"03-6253277","Email":"","Address":"\u05e8\u05d7\u05d5\u05d1 \u05d9\u05e6\u05d7\u05e7 \u05e9\u05d3\u05d4 7 \u05ea\u05dc \u05d0\u05d1\u05d9\u05d1, 67775","Twitter":"fibiblog","Facebook":"facebook.com\/pages\/hbynlwmy\/106329716062251","GooglePlus":"","App_iOS":"http:\/\/itunes.apple.com\/il\/app\/hbnq-hbynl-wmy\/id419704429","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Fibi.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":6},{"CompanyGUID":"F46F2D5F-322B-4944-923B-3C1D08F96ADF","CompanyID":246,"CategoryID":20,"Name":"TheMarker","NameEn":"TheMarker","Description":"","WebSite":"www.themarker.com","Num":"1-700-700-250","Num2":"","FaxNum":"","Email":"customer_service@haaretz.co.il","Address":"\u05e9\u05d1\u05d9\u05dc \u05d4\u05de\u05e8\u05e5 2 \u05ea.\u05d3. 35029, \u05ea\u05dc-\u05d0\u05d1\u05d9\u05d1 61350","Twitter":"TheMarker","Facebook":"facebook.com\/TheMarkerOnline","GooglePlus":"","App_iOS":"http:\/\/itunes.apple.com\/il\/app\/themarker-dmrqr\/id360938308","App_Android":"https:\/\/play.google.com\/store\/apps\/details?id=com.casualmobile.themarker","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"TheMarker.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":6},{"CompanyGUID":"96ED69AF-B691-48C3-A370-3C9CBF8B226F","CompanyID":166,"CategoryID":3,"Name":"\u05d9\u05e9\u05d9\u05e8 \u05dc\u05d0\u05d5\u05de\u05d9","NameEn":"LeumiY","Description":"","WebSite":"www.yashirleumi.co.il","Num":"*5524","Num2":"03-9545524","FaxNum":"03-9544324","Email":"yashirleumi@yashirl.co.il","Address":"\u05ea\"\u05d3 98580 \u05dc\u05d5\u05d3 71336","Twitter":"YashirLeumi","Facebook":"","GooglePlus":"","App_iOS":"","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"help1.bankleumi.co.il\/rl\/yashir_tech.html","Icon":"LeumiY.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":6},{"CompanyGUID":"7985AAF2-12FE-40D4-98D5-3E09BEC1C348","CompanyID":127,"CategoryID":6,"Name":"\u05e8\u05db\u05d1\u05ea \u05d9\u05e9\u05e8\u05d0\u05dc","NameEn":"Rail","Description":"","WebSite":"www.rail.co.il","Num":"*5770","Num2":"03-6117000","FaxNum":"03-6104337","Email":"pniyot@rail.co.il","Address":"\u05ea\u05d7\u05e0\u05ea \u05e8\u05db\u05d1\u05ea \u05ea\"\u05d0 \u05e1\u05d1\u05d9\u05d3\u05d5\u05e8 \u05de\u05e8\u05db\u05d6 \u05ea.\u05d3 18085 \u05de\u05d9\u05e7\u05d5\u05d3 61180","Twitter":"IsraelRail","Facebook":"facebook.com\/irail","GooglePlus":"","App_iOS":"http:\/\/itunes.apple.com\/il\/app\/israel-train-schedule\/id335527987","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Rail.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":7},{"CompanyGUID":"D5B924B8-64EF-4451-A5B1-405ACE0D998C","CompanyID":183,"CategoryID":7,"Name":"\u05d0\u05d5\u05d5\u05d9\u05e1","NameEn":"Avis","Description":"","WebSite":"www.avis.co.il","Num":"*2722","Num2":"03-6170000","FaxNum":"","Email":"sharons@avis.co.il.","Address":"\u05d1\u05e8\u05d5\u05da \u05d4\u05d9\u05e8\u05e9 14 \u05d1\u05e0\u05d9 \u05d1\u05e8\u05e7","Twitter":"AvisWeTryHarder","Facebook":"facebook.com\/Avis.Israel","GooglePlus":"","App_iOS":"http:\/\/itunes.apple.com\/il\/app\/avis-israel\/id392534621","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Avis.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":7},{"CompanyGUID":"0D871609-0E8F-4239-9B98-4507125D207B","CompanyID":244,"CategoryID":20,"Name":"\u05de\u05e7\u05d5\u05e8 \u05e8\u05d0\u05e9\u05d5\u05df","NameEn":"Makor1","Description":"","WebSite":"www.makor1.co.il","Num":"03-6277777","Num2":"03-6277700","FaxNum":"","Email":"","Address":"\u05d3\u05e8\u05da \u05de\u05e0\u05d7\u05dd \u05d1\u05d2\u05d9\u05df 116 \u05ea\u05dc \u05d0\u05d1\u05d9\u05d1","Twitter":"","Facebook":"facebook.com\/mekorrishon","GooglePlus":"","App_iOS":"","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Makor1.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":5},{"CompanyGUID":"4C17E487-240F-4998-B427-49BAC1299D29","CompanyID":133,"CategoryID":9,"Name":"\u05d3\u05d5\u05d0\u05e8 \u05d9\u05e9\u05e8\u05d0\u05dc","NameEn":"Post","Description":"","WebSite":"www.israelpost.co.il","Num":"171","Num2":"1-599-500-171","FaxNum":"","Email":"","Address":"\u05e8\u05d7\u05d5\u05d1 \u05d9\u05e4\u05d5 30, \u05d9\u05e8\u05d5\u05e9\u05dc\u05d9\u05dd 91999","Twitter":"Doar_Israel","Facebook":"facebook.com\/PostIsrael","GooglePlus":"","App_iOS":"http:\/\/itunes.apple.com\/il\/app\/hdw-r-sl-ysr-l\/id495504465","App_Android":"","App_WinPhone":"","App_BlackBerry":"","Blog":"","Chat":"","Icon":"Post.png","SearchTags":null,"Rating":null,"Public":1,"ToShow":1,"Revision":7},...]}

提前致谢!

1 个答案:

答案 0 :(得分:1)

尝试以下方法:

    [DataContract]
public class Brands
{
    [DataMember]
    public ObservableCollection<Brand> data;
}

[DataContract(Name = "data")]
public class Brand
{/* 
public string BrandName; 
public int BrandId; 
   */
    [DataMember]
    public string CompanyGUID;
    [DataMember]
    public int CompanyID; 
    [DataMember]
    public int CategoryID;
    [DataMember]
    public string Name;
    [DataMember]
    public string NameEn;
    [DataMember]
    public string Description;
    [DataMember]
    public string WebSite;
    [DataMember]
    public string Num;
    [DataMember]
    public string Num2;
    [DataMember]
    public string FaxNum;
    [DataMember]
    public string Email;
    [DataMember]
    public string Address;
    [DataMember]
    public string Twitter;
    [DataMember]
    public string Facebook;
    [DataMember]
    public string GooglePlus;
    [DataMember]
    public string App_iOS;
    [DataMember]
    public string App_Android;
    [DataMember]
    public string App_WinPhone;
    [DataMember]
    public string App_BlackBerry;
    [DataMember]
    public string Blog;
    [DataMember]
    public string Chat;
    [DataMember]
    public string Icon;
    [DataMember]
    public string SearchTags;
    [DataMember]
    public double Rating;
    [DataMember]
    public int Public;
    [DataMember]
    public int ToShow;
    [DataMember]
    public int Revision;
} 

然后改为:

void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
    {

        DataContractJsonSerializer serializer = null;
        try
        {
            serializer = new DataContractJsonSerializer(typeof(Brands));
            var Brands = (Brands)serializer.ReadObject(e.Result);

            foreach (Brand b in Brands.data)
            {
                int id = b.CompanyID;
                string name = b.Name;
                //listBrands.Items.Add(id + "             " + name);

            }

        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        } 
    }

在webClient_OpenReadCompleted方法中。

...欢呼声

它应该有用,

欢呼声,