Home >Backend Development >C++ >How Can I Parse JSON in Metro Applications Without JSON.NET?
Parsing JSON Without JSON.NET in Metro Applications
Metro applications developed within Visual Studio 2011 necessitate alternative methods for JSON parsing. This is because the well-known JSON.NET library has yet to incorporate support for Metro platforms.
To circumvent this limitation, developers can leverage the classes available within the System.Json namespace, which was introduced in .NET 4.5. After adding a reference to the System.Runtime.Serialization assembly, the following steps can be followed:
JsonValue value = JsonValue.Parse(@"{ ""name"":""Prince Charming"", ...");
using System.Json; JsonObject result = value as JsonObject;
Console.WriteLine("Name .... {0}", (string)result["name"]); Console.WriteLine("Artist .. {0}", (string)result["artist"]); Console.WriteLine("Genre ... {0}", (string)result["genre"]); Console.WriteLine("Album ... {0}", (string)result["album"]);
These classes exhibit a similar structure to those found within the System.Xml.Linq namespace, making them relatively familiar for developers working in .NET.
The above is the detailed content of How Can I Parse JSON in Metro Applications Without JSON.NET?. For more information, please follow other related articles on the PHP Chinese website!