@@ -508,6 +508,20 @@ public void Can_Deserialize_To_Dictionary_String_String()
508508 Assert . Equal ( bd [ "ThingBlue" ] , "ThingBlue" ) ;
509509 }
510510
511+ [ Fact ]
512+ public void Can_Deserialize_To_Dictionary_String_String_With_Dynamic_Values ( )
513+ {
514+ var doc = CreateDynamicJsonStringDictionary ( ) ;
515+ var d = new JsonDeserializer ( ) ;
516+ var response = new RestResponse { Content = doc } ;
517+ var bd = d . Deserialize < Dictionary < string , string > > ( response ) ;
518+
519+ Assert . Equal ( "[\" Value1\" ,\" Value2\" ]" , bd [ "Thing1" ] ) ;
520+ Assert . Equal ( "Thing2" , bd [ "Thing2" ] ) ;
521+ Assert . Equal ( "{\" Name\" :\" ThingRed\" ,\" Color\" :\" Red\" }" , bd [ "ThingRed" ] ) ;
522+ Assert . Equal ( "{\" Name\" :\" ThingBlue\" ,\" Color\" :\" Blue\" }" , bd [ "ThingBlue" ] ) ;
523+ }
524+
511525 private string CreateJsonWithUnderscores ( )
512526 {
513527 var doc = new JObject ( ) ;
@@ -678,5 +692,15 @@ public string CreateJsonStringDictionary()
678692 doc [ "ThingBlue" ] = "ThingBlue" ;
679693 return doc . ToString ( ) ;
680694 }
695+
696+ public string CreateDynamicJsonStringDictionary ( )
697+ {
698+ var doc = new JObject ( ) ;
699+ doc [ "Thing1" ] = new JArray ( ) { "Value1" , "Value2" } ;
700+ doc [ "Thing2" ] = "Thing2" ;
701+ doc [ "ThingRed" ] = new JObject ( new JProperty ( "Name" , "ThingRed" ) , new JProperty ( "Color" , "Red" ) ) ;
702+ doc [ "ThingBlue" ] = new JObject ( new JProperty ( "Name" , "ThingBlue" ) , new JProperty ( "Color" , "Blue" ) ) ;
703+ return doc . ToString ( ) ;
704+ }
681705 }
682706}
0 commit comments