You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice if the Theme could be JSON Serializeable. At the moment I get following Exception for 'MudBlazor.Utilities.MudColor'
Unhandled exception rendering component: Deserialization of types without a parameterless constructor, a singular parameterized constructor, or a parameterized constructor annotated with 'JsonConstructorAttribute' is not supported. Type 'MudBlazor.Utilities.MudColor'. Path: $.Theme.Palette.Black | LineNumber: 0 | BytePositionInLine: 30.
System.NotSupportedException: Deserialization of types without a parameterless constructor, a singular parameterized constructor, or a parameterized constructor annotated with 'JsonConstructorAttribute' is not supported. Type 'MudBlazor.Utilities.MudColor'. Path: $.Theme.Palette.Black | LineNumber: 0 | BytePositionInLine: 30.
---> System.NotSupportedException: Deserialization of types without a parameterless constructor, a singular parameterized constructor, or a parameterized constructor annotated with 'JsonConstructorAttribute' is not supported. Type 'MudBlazor.Utilities.MudColor'.
--- End of inner exception stack trace ---
It would be nice if the Theme could be JSON Serializeable. At the moment I get following Exception for 'MudBlazor.Utilities.MudColor'
Unhandled exception rendering component: Deserialization of types without a parameterless constructor, a singular parameterized constructor, or a parameterized constructor annotated with 'JsonConstructorAttribute' is not supported. Type 'MudBlazor.Utilities.MudColor'. Path: $.Theme.Palette.Black | LineNumber: 0 | BytePositionInLine: 30.
System.NotSupportedException: Deserialization of types without a parameterless constructor, a singular parameterized constructor, or a parameterized constructor annotated with 'JsonConstructorAttribute' is not supported. Type 'MudBlazor.Utilities.MudColor'. Path: $.Theme.Palette.Black | LineNumber: 0 | BytePositionInLine: 30.
---> System.NotSupportedException: Deserialization of types without a parameterless constructor, a singular parameterized constructor, or a parameterized constructor annotated with 'JsonConstructorAttribute' is not supported. Type 'MudBlazor.Utilities.MudColor'.
--- End of inner exception stack trace ---
You can use Newtonsoft.Json to deserialize the same as I was also getting same error while deserializing with System.Text.Json
With Newtonsoft we are able serialize the ThemeManagerTheme object but not with System.Text.JSON. So for this particular case we used Newtonsoft to save the object,
Is opening and saving a theme is now supported from the theme manager itself? There is the option to load a preset but it's saying "Not Implemented". Is it planned to work soon?
By the way, the MudColorSerializer should no longer be necessary if you are using MudBlazor v7. In MudBlazor v7, I have implemented native support for System.Text.Json and Newtonsoft. You can find more information at MudBlazor/MudBlazor#8579.
Is opening and saving a theme is now supported from the theme manager itself? There is the option to load a preset but it's saying "Not Implemented". Is it planned to work soon?
There are no current plans for this. This repository has a very low priority and is in maintenance mode, with only myself handling it when it breaks with new versions of MudBlazor. However, you can submit a pull request with this feature, and I would gladly review and accept it.
Activity
Garderoben commentedon Sep 17, 2021
Currently not possible, but its a feature i plan to add, but i am prioritizing the main library atm.
TheR00st3r commentedon Apr 19, 2022
It would be nice if the Theme could be JSON Serializeable. At the moment I get following Exception for 'MudBlazor.Utilities.MudColor'
Logi-Fy-Pravin commentedon Apr 20, 2022
You can use Newtonsoft.Json to deserialize the same as I was also getting same error while deserializing with System.Text.Json
echannelsolutions commentedon May 15, 2023
With Newtonsoft we are able serialize the ThemeManagerTheme object but not with System.Text.JSON. So for this particular case we used Newtonsoft to save the object,
PhilippRoessner commentedon Nov 23, 2023
I'd like to add the request to also load a deserialized json into the mudblazor ThemeProvider. I couldn't figure out any way to accomplish that
ScarletKuro commentedon Nov 23, 2023
Theoretically you can write custom JsonConverter and it should work.
For example a custom
MudColorconverter forSystem.Text.Jsonthat is working.You just need to add it to the
JsonSerializerOptions.ConvertersPhilippRoessner commentedon Nov 24, 2023
Thanks! It works perfectly. I had to change this:
string propName = reader.GetString();because my json exported with capital letters
string propName = reader.GetString().ToLower();For Anyone who needs a copy/paste of using this:
vanthomiy commentedon Aug 14, 2024
Is opening and saving a theme is now supported from the theme manager itself? There is the option to load a preset but it's saying "Not Implemented". Is it planned to work soon?
ScarletKuro commentedon Aug 14, 2024
By the way, the
MudColorSerializershould no longer be necessary if you are using MudBlazor v7. In MudBlazor v7, I have implemented native support for System.Text.Json and Newtonsoft. You can find more information at MudBlazor/MudBlazor#8579.There are no current plans for this. This repository has a very low priority and is in maintenance mode, with only myself handling it when it breaks with new versions of MudBlazor. However, you can submit a pull request with this feature, and I would gladly review and accept it.