❔ How can I access a member of a different class in a dictionary
Hey! I'm trying to refactor my old JSON serializer code, but I ran into an issue. I can't access a string in another class named
RssTitle
. In this Content
property, there are 3 different strings that I need to access, RssTitle, RssDesc, and RssPubDate. When I use a dictionary like this:
It can't access those 3 strings, and just says that RssTitle does not exist in the current context
. Here is the data model behind this code
If I use a List
, like this: public List<ContentList> Content { get; set; }
, it creates an array in the serialized JSON. I need it to not be an array. Here's what the final JSON looks like:
I need it to look like this:
4 Replies
So why is your property a
Dictionary<ContentList, string>
instead of just a ContentList
^
Seems like you didn't know whether to use
ContentList
or a Dictionary<string, string>
so you tried using them bothYeah, I tried using them both. I thought you needed both to make it work. Thanks!
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.