© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
10 replies
Pdawg

❔ Adding logic into a JSON serializer

Hey everyone! I need to add logic into a json object, but I can't add any code in there or else it'll break. Here is what I mean: If I have a
Dictionary
Dictionary
named Icons, I need to say
foreach item selected from the filepicker, create a new keypair in the Dictionary
foreach item selected from the filepicker, create a new keypair in the Dictionary
. Basically, the user selects a few .png files, the code needs to copy them to a folder and add those names to the dictionary. Here is my current code that is a static dictionary:

private async void SerializeJSON()
        {
            var model = new ObjectModel
            {
                ManifestVersion = 1,
                Name = TileTitle,
                Description = DescriptionTile,
                Version = 1,
                VersionString = "1",
                Author = AuthorTile,
                Organization = OrgTile,
                ContactEmail = TileEmail,
                TileIcon = new Dictionary<int, string>
                {
                    [46] = "icons/tileIcon.png"
                },
                BadgeIcon = new Dictionary<int, string>
                {
                    [24] = "icons/badgeIcon.png"
                },
                Icons = new Dictionary<string, string>
                {
                    ["iconTest"] = "newIcon1.png" // I need to add more items here when needed, based on what is pulled from the filepicker
                },
            };
        }
private async void SerializeJSON()
        {
            var model = new ObjectModel
            {
                ManifestVersion = 1,
                Name = TileTitle,
                Description = DescriptionTile,
                Version = 1,
                VersionString = "1",
                Author = AuthorTile,
                Organization = OrgTile,
                ContactEmail = TileEmail,
                TileIcon = new Dictionary<int, string>
                {
                    [46] = "icons/tileIcon.png"
                },
                BadgeIcon = new Dictionary<int, string>
                {
                    [24] = "icons/badgeIcon.png"
                },
                Icons = new Dictionary<string, string>
                {
                    ["iconTest"] = "newIcon1.png" // I need to add more items here when needed, based on what is pulled from the filepicker
                },
            };
        }
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Json Serializer implicit conversion
C#CC# / help
3y ago
Custom JSON serializer not working
C#CC# / help
4y ago
urgent ! it's related with json serializer
C#CC# / help
3y ago
✅ Can't figure out json logic
C#CC# / help
2y ago