C# Windows phone REST API';s

C# Windows phone REST API';s,c#,wpf,visual-studio,windows-phone-8,C#,Wpf,Visual Studio,Windows Phone 8,我想在我的网页中显示Windows Phone 8.1中的数据 所以我将这个JSON作为类粘贴到FSfeed.cs中 public class Rootobject { public Class1[] Property1 { get; set; } } public class Class1 { public string name { get; set; } public string picture_url { get; set; } public stri

我想在我的网页中显示Windows Phone 8.1中的数据

所以我将这个JSON作为类粘贴到FSfeed.cs中

public class Rootobject
{
    public Class1[] Property1 { get; set; }
}

public class Class1
{
    public string name { get; set; }
    public string picture_url { get; set; }
    public string city { get; set; }
    public string date { get; set; }
}
然后调用API并将响应存储在一个变量中:(BasipPage1.xaml.cs)


有人知道我做错了什么吗?

您的json是一个数组/列表(请参见
[{…},{…}]
)。您应该反序列化到
列表

var FSfeed=JsonConvert.DeserializeObject(响应);
Reviews.ItemsSource=FSfeed;

哦,这是个新手犯的错误!非常感谢,解决了我的问题:)@kac26然后看这个
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
    this.navigationHelper.OnNavigatedTo(e);
    HttpClient http = new HttpClient();

    var response = await http.GetStringAsync("http://www.veligovsek.si/events/apis/events.php");

    var FSfeed = JsonConvert.DeserializeObject<Rootobject>(response);

    Reviews.ItemsSource = FSfeed.Property1;
}
<Page
    x:Class="EventHub.BasicPage1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:EventHub"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Page.Background>
        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="Black" Offset="0"/>
            <GradientStop Color="White" Offset="1"/>
        </LinearGradientBrush>
    </Page.Background>

    <Grid x:Name="LayoutRoot" Background="#FFFF8A00">

        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Title Panel -->
        <StackPanel Grid.Row="0" Margin="19,0,0,0">
            <StackPanel.Background>
                <ImageBrush Stretch="Fill"/>
            </StackPanel.Background>
        </StackPanel>

        <!--TODO: Content should be placed within the following grid-->
        <Grid x:Name="ContentRoot" Margin="0,129,0,0" Grid.RowSpan="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="199*"/>
                <ColumnDefinition Width="201*"/>
            </Grid.ColumnDefinitions>

            <ListView  x:Name="Reviews" Grid.ColumnSpan="2" HorizontalAlignment="Right" Width="400" Margin="0,10,0,0">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}" Width="110" Height="110">
                                <Image Source="http://www.nasa.gov/images/content/64883main_image_feature_211_jw4.jpg" Stretch="UniformToFill" />
                            </Border>
                            <StackPanel Grid.Column="1" VerticalAlignment="Top" Orientation="Vertical" Margin="10,0,0,0">
                                <TextBlock Text="{Binding Class1.name}"/>
                                <TextBlock Text="{Binding Class1.city}"  MaxHeight="60"/>
                            </StackPanel>
                        </StackPanel>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>



        </Grid>
        <Grid x:Name="asd" HorizontalAlignment="Left" Height="129" Grid.RowSpan="2" VerticalAlignment="Top" Width="400">

            <AppBarButton RenderTransformOrigin="0.5,0.5" Height="55" Width="67" Margin="153,33,0,0" Icon="Home">
                <AppBarButton.RenderTransform>
                    <CompositeTransform ScaleX="2" ScaleY="2"/>
                </AppBarButton.RenderTransform>
            </AppBarButton>
        </Grid>

    </Grid>

    <Page.BottomAppBar>
        <CommandBar IsSticky="True" x:Name="appBar">
            <CommandBar.PrimaryCommands>
                <AppBarButton Icon="Refresh" Label="refresh"/>
                <AppBarButton x:Name="capture"  Icon="Scan" Label="capture" Click="capture_Click"/>
            </CommandBar.PrimaryCommands>
            <CommandBar.SecondaryCommands>
                <AppBarButton Label="settings"/>
                <AppBarButton x:Name="PinUnPinCommandButton" Label="pin to start" Click="PinUnPinCommandButton_Click"/>
                <AppBarButton x:Name="about" Label="about" Click="about_click"/>
                <AppBarButton x:Name="logout" Label="log out" Click="logout_Click"/>
            </CommandBar.SecondaryCommands>
        </CommandBar>

    </Page.BottomAppBar>

</Page>
            if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
var FSfeed = JsonConvert.DeserializeObject<List<Class1>>(response);
Reviews.ItemsSource = FSfeed;