title: Build mongo hex object ID from its components e.g. timestamp,. counter, random value
body: <p>I have a program that marshals the mongo BSON to JSON, where the mongo object ID is represented by its components:</p>
  <pre><code>&quot;id&quot;: {
      &quot;date&quot;: 1487703734000,
      &quot;timestamp&quot;: 1487703734,
      &quot;counter&quot;: 14046291,
      &quot;processIdentifier&quot;: 24019,
      &quot;machineIdentifier&quot;: 6597369,
      &quot;timeSecond&quot;: 1487703734,
      &quot;time&quot;: 1487703734000
    } 
  </code></pre>
  <p>Can I convert this into the hexadecimal mongo ID? I can see in <a href="https://docs.mongodb.com/manual/reference/bson-types/#objectid" rel="nofollow noreferrer">the mongo object ID docs</a> how it is composed, but I'm not sure if I have what they are referring to as the &quot;random value&quot; in my JSON. (appears I do have the timestamp and counter though)</p>
  <p>Any help is appreciated. Thanks</p>