uwp开发之Windows.​Data.​Json解析json

方法1

 Namespace  Windows.​Data.​Json

github.com/Microsoft/Windows-universal-samples/tree/master/Samples/XamlUIBasics/cs/AppUIBasics/DataModel  文件夹下

ControlInfoData.json
ControlInfoDataSource.cs


"Groups": [
  {
  "UniqueId": "AppBars",
  "Title": "App bars and commands",
  "Subtitle": "AppBar, CommandBar, AppBarButton, AppBarToggleButton, AppBarSeparator",
  "ImagePath": "ms-appx:///Assets/CommandBar.png",
  "Description": "Use app bars to present navigation, commands, and tools to users.",
  "Items": [
  {
  "UniqueId": "AppBar",
  "Title": "AppBar",
  "Subtitle": "A toolbar for displaying application-specific commands, navigation, and tools.",
  "ImagePath": "ms-appx:///Assets/AppBar.png",
  "Description": "An app bar is a UI element that presents navigation, commands, and tools to the user. An app bar can appear at the top of the page, at the bottom of the page, or both. It is hidden by default, and is shown or dismissed when the user right clicks, presses Windows+Z, or swipes from the top or bottom edge of the screen.",
  "Content": "<p>This page shows a simplified navigation bar to demonstrate basic <b>AppBar</b> usage. When you resize the page (by placing apps side-by-side, for example), the </b>AppBar</b> control doesn't resize it's content, so you have to manage that yourself. Look at the <i>AppBarPage.xaml</i> file in Visual Studio to see this simplified app bar. </p><p>This app also uses a shared <b>AppBar</b> in NavigationRootPage for navigation. To see an example of more complex app bar content, look at the files in the <i>Navigation</i> folder in Visual Studio.</p>",
  "Docs": [
  { "Title": "AppBar", "Uri": "http://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.controls.appbar.aspx" },
  { "Title": "Quickstart: Adding app bars", "Uri": "http://msdn.microsoft.com/en-us/library/windows/apps/hh781232.aspx" }
  ],
  "RelatedControls": [
  "CommandBar",
  "AppBarButton",
  "AppBarToggleButton",
  "AppBarSeparator"
  ]
  },
  {
  "UniqueId": "CommandBar",
  "Title": "CommandBar",
  "Subtitle": "A toolbar for displaying application-specific commands that handles layout and resizing of its contents.",
  "ImagePath": "ms-appx:///Assets/CommandBar.png",
  "Description": "The CommandBar simplifies the creation of basic app bars by providing:\n- Automatic layout of commands, with primary commands on the right and secondary commands on the left.\n- Automatic resizing of app bar commands when the app size changes.\nWhen you need an app bar that contains only AppBarButton,AppBarToggleButton , and AppBarSeparator controls, use a CommandBar. If you need more complex content, such as images, progress bars, or text blocks, use an AppBar control.",
  "Content": "<p>The bottom app bar on this page is a <b>CommandBar</b> control.</p><p>Add secondary commands and then resize the app to see how the <b>CommandBar</b> automatically adapts to different widths.</p><p>This <b>CommandBar</b> element is in the ItemPage so it can be shared across all control pages in the app. Look at the <i>ItemPage.xaml</i> file in Visual Studio to see the full code for this page.</p>",
  "Docs": [
  { "Title": "CommandBar", "Uri": "http://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.controls.commandbar.aspx" },
  { "Title": "Quickstart: Adding app bars", "Uri": "http://msdn.microsoft.com/en-us/library/windows/apps/hh781232.aspx" }
  ],
  "RelatedControls": [
  "AppBar",
  "AppBarButton",
  "AppBarToggleButton",
  "AppBarSeparator"
  ]
  },


using Windows.Data.Json;
using Windows.Storage;
Uri dataUri = new Uri("ms-appx:///DataModel/ControlInfoData.json");
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(dataUri);
string jsonText = await FileIO.ReadTextAsync(file);


JsonObject jsonObject = JsonObject.Parse(jsonText);
JsonArray jsonArray = jsonObject["Groups"].GetArray();





方法2 newtonsoft.json






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值