File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed
OpenBioCardServer/Utilities/Mappers Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,8 @@ private static ClassicSocialLink ToClassicSocialLink(SocialLinkItemEntity s)
6666 {
6767 try
6868 {
69- githubData = JsonSerializer . Deserialize < Dictionary < string , object > > ( s . AttributesJson ) ;
69+ using var doc = JsonDocument . Parse ( s . AttributesJson ) ;
70+ githubData = ConvertJsonElementToObject ( doc . RootElement ) as Dictionary < string , object > ;
7071 }
7172 catch { /* Ignore deserialization errors */ }
7273 }
@@ -78,6 +79,29 @@ private static ClassicSocialLink ToClassicSocialLink(SocialLinkItemEntity s)
7879 GithubData = githubData
7980 } ;
8081 }
82+
83+ // Convert JsonElement to actual .NET types
84+ private static object ? ConvertJsonElementToObject ( JsonElement element )
85+ {
86+ return element . ValueKind switch
87+ {
88+ JsonValueKind . Object => element . EnumerateObject ( )
89+ . ToDictionary (
90+ prop => prop . Name ,
91+ prop => ConvertJsonElementToObject ( prop . Value ) !
92+ ) ,
93+ JsonValueKind . Array => element . EnumerateArray ( )
94+ . Select ( ConvertJsonElementToObject )
95+ . ToList ( ) ,
96+ JsonValueKind . String => element . GetString ( ) ! ,
97+ JsonValueKind . Number => element . TryGetInt64 ( out var l ) ? l : element . GetDouble ( ) ,
98+ JsonValueKind . True => true ,
99+ JsonValueKind . False => false ,
100+ JsonValueKind . Null => null ,
101+ _ => null
102+ } ;
103+ }
104+
81105
82106 private static ClassicProject ToClassicProject ( ProjectItemEntity p ) => new ( )
83107 {
You can’t perform that action at this time.
0 commit comments