title: How to convert primitive.M to map [string]string then to string?
body: <p>How can we convert primitive M to string?</p>
  <pre class="lang-golang prettyprint-override"><code>package main
  
  import (
      &quot;go.mongodb.org/mongo-driver/bson&quot;
  )
  
  func main() {
      a := bson.M{ // primitive.M
          &quot;test&quot;: bson.M{
              &quot;fielda&quot;: &quot;AAA&quot;,
              &quot;fieldb&quot;: &quot;BBB&quot;,
          },
      }
  }
  </code></pre>
  <p>I'm using this to log mongodb documents that are failing in process.
  I was able to print the value using <code>logrus.Error</code>, I want to replicate this convert to string and then log it to file.</p>
  <pre class="lang-golang prettyprint-override"><code>// cursor = &quot;go.mongodb.org/mongo-driver/mongo&quot; *mongo.Cursor
  // logrus = &quot;github.com/sirupsen/logrus&quot;
  //...
          var temp bson.M
          _ := cursor.Decode(&amp;temp)     // assume this is not returning error, it will log the map
          logrus.Error(&quot;value: &quot;, temp) // value: map[__v:0 _id:ObjectID(\&quot;5c8ef7df7216e9935ecd7859\&quot;) field1:test]
  </code></pre>