How can I correctly extract metafields values in JSON code?

This gets the metafield by namespace/key and outputs the value. “first” is needed because “where” returns a list.

{%- assign mf_object = product.metafields | where: "namespace", "my_fields" | where: "key", "pattern" | first -%} 
{{ mf_object.value }}