【发布时间】:2022-01-17 15:54:48
【问题描述】:
我有一个本地 JSON 文件。我需要解析该文件中的数据并需要一个包含日期、颜色和消息详细信息的列表。
JSON 文件中的数据格式:
{"01-01-2017":{"color":"white","message":"The Octave Day of Christmas Solemnity of the Blessed Virgin Mary, the Mother of God Lectionary: 18"},"02-01-2017":{"color":"white","message":"Memorial of Saints Basil the Great and Gregory Nazianzen, Bishops and Doctors of the Church Lectionary: 205",.......}}
模型类
public class JsonContent
{
public string date { get; set; }
public string color { get; set; }
public string message { get; set; }
}
我尝试了以下代码:
string jsonString;
string jsonFileName = "Files.prayers.json";
var assembly = typeof(HomePage1).GetTypeInfo().Assembly;
Stream stream = assembly.GetManifestResourceStream($"{assembly.GetName().Name}.{jsonFileName}");
using (var reader = new System.IO.StreamReader(stream))
{
jsonString = reader.ReadToEnd();
}
List <JsonContent> newList = new List<JsonContent>();
//I need to add all the items into the above list
如何获取包含日期、颜色和消息详细信息的列表?在此之后,我需要在XamForms.Enhanced.Calendar 上用颜色显示日期。我知道如何在日历中显示特殊日期,但停留在这个数据解析上。
【问题讨论】:
-
@Jason 我们已经更新了这个问题的更多细节,你能看看吗?
标签: xamarin.forms