Replies: 1 comment 1 reply
-
I was able to do this. var items = TocItem.Create(Metadata.GetList<IMetadataDictionary>("toc")); public class TocItem
{
public string Title { get; set; }
public string Link { get; set; }
public List<TocItem> Children { get; set; } = new List<TocItem>();
public static TocItem Create(IMetadataDictionary data)
{
var tocItem = new TocItem()
{
Title = data.Get<string>("title"),
Link = data.Get<string>("link"),
};
if (data.ContainsKey("children"))
{
tocItem.Children = Create(data.GetList<IMetadataDictionary>("children"));
}
return tocItem;
}
public static List<TocItem> Create(IEnumerable<IMetadataDictionary> objects) => objects?.Select(Create).ToList() ?? new List<TocItem>();
} Not sure if this is the best way. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a file
_index.json
alongside my markdown file and I'm trying to get data out of it.My json file looks like this.
My type looks like this.
I tried different variations of getting values out.
Is there a way to do this?
I'd be happy if I could get the raw JSON at "toc" and just use Newtonsoft to deserialize it.
Beta Was this translation helpful? Give feedback.
All reactions