@@ -253,47 +253,15 @@ private string HashHMAC(string key, string message)
253253 byte [ ] hash = new HMACSHA256 ( Encoding . UTF8 . GetBytes ( key ) ) . ComputeHash ( new UTF8Encoding ( ) . GetBytes ( message ) ) ;
254254 return BitConverter . ToString ( hash ) . Replace ( "-" , "" ) . ToLower ( ) ;
255255 }
256-
257- // FIXME
258256 private Dictionary < string , string > GetParameters ( object parameters )
259257 {
260258 var dictionaryParameters = new Dictionary < string , string > ( ) ;
261259
262- if ( parameters != null )
260+ if ( parameters is JsonElement jsonElement )
263261 {
264- // Serialize the input object to JSON.
265- string json = JsonSerializer . Serialize ( parameters , DefaultJsonSerializerOptions . SerializerOptions ) ;
266-
267- // Parse the JSON using JsonDocument.
268- using ( var doc = JsonDocument . Parse ( json ) )
262+ foreach ( JsonProperty prop in jsonElement . EnumerateObject ( ) )
269263 {
270- var root = doc . RootElement ;
271- if ( root . ValueKind == JsonValueKind . Object )
272- {
273- foreach ( JsonProperty prop in root . EnumerateObject ( ) )
274- {
275- string valueStr ;
276- // Replicate JToken.ToString() behavior:
277- // For string values, return the unquoted string.
278- // For objects and arrays, serialize them to JSON.
279- // Otherwise, use the default ToString().
280- switch ( prop . Value . ValueKind )
281- {
282- case JsonValueKind . String :
283- valueStr = prop . Value . GetString ( ) ;
284- break ;
285- case JsonValueKind . Object :
286- case JsonValueKind . Array :
287- valueStr = JsonSerializer . Serialize ( prop . Value , DefaultJsonSerializerOptions . SerializerOptions ) ;
288- break ;
289- default :
290- valueStr = prop . Value . ToString ( ) ;
291- break ;
292- }
293-
294- dictionaryParameters [ prop . Name ] = valueStr ;
295- }
296- }
264+ dictionaryParameters [ prop . Name ] = prop . Value . GetString ( ) ;
297265 }
298266 }
299267
0 commit comments