I'm a novice developer for WP. I have some problems with parsing json data. I take it from the server and parse with JSON.Net.
Example of JSON data
{"response":
{"ad6a95dd8f90fad7e281994cb5a8cacd":
{"status":"offline", "name": "Test Name",
"id":"ad6a95dd8f90fad7e281994cb5a8cacd"}
}
"success":true
}
The first chield of "response" varies with each request to the server. How I can extract value of "name" field ?! Thank you in advance for your reply.
I try that in Page.xaml.cs
var o = JObject.Parse(result);
var id = o["response"].First;
ServerList.ItemsSource = id;
and in Page.xaml
<ScrollViewer Foreground="White">
<ListBox Margin="0,0,-12,0" Name="ServerList" Height="508" Width="415">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,20" Width="300">
<TextBlock Text="{Binding Path=name}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</ScrollViewer>
I did it by example.
var id ={"ad6a95dd8f90fad7e281994cb5a8cacd": {"status":"offline", "name": "Test Name", "id":"ad6a95dd8f90fad7e281994cb5a8cacd"}instead this{"status":"offline", "name": "Test Name", "id":"ad6a95dd8f90fad7e281994cb5a8cacd"}