Home >Backend Development >C++ >How to Parse JSON with Invalid C# Identifier Property Names?
Consider the JSON string provided, which contains digital attribute names, which will hinder the creation of traditional C# class. To effectively analyze this JSON, we can use dictionary instead of class.
<code class="language-csharp">public class Item { public string fajr { get; set; } public string sunrise { get; set; } public string zuhr { get; set; } public string asr { get; set; } public string maghrib { get; set; } public string isha { get; set; } } // 使用字典代替类 var dict = JsonConvert.DeserializeObject<Dictionary<string, string>>(json); </code>Through this method, we can successfully analyze the JSON string and use the attribute name to access the data, even if they are invalid C# logo in the traditional class structure.
The above is the detailed content of How to Parse JSON with Invalid C# Identifier Property Names?. For more information, please follow other related articles on the PHP Chinese website!