title: MongoDB: how to access numerical keys in the map
body: <p>I have the below document in my collection</p>
  
  
  
  <pre class="lang-js prettyprint-override"><code>{ 
      "_id" : ObjectId("53732dc386d78e446c73fbb3"),
      "elig" : 18,
      "tags" : { 
          "6" : "49.6", 
          "9" : "657"
      }, 
      "book" : { 
          "type" : "100",
         "id" : "59598699"
      }
  }
  </code></pre>
  
  <p>If you notice , the tags is key-value pair with the keys in numerical form (basically FIX messages, tag and value pair )</p>
  
  <p>I need to update tags.6 from String ("49.6") to Float (49.6).</p>
  
  <p>When I tried for updating the book.type from "100" to 100, it worked. Below worked. </p>
  
  <pre class="lang-js prettyprint-override"><code>db.coll.find().forEach(function(data) {
      db.coll.update(
          {_id:data._id},
          {$set:{"book.type":parseFloat(data.book.type) }}
      );
  })
  </code></pre>
  
  <p>But for tags.6,:</p>
  
  <pre class="lang-js prettyprint-override"><code>db.coll.find().forEach(function(data) {
      db.coll.update(
          {_id:data._id},
          {$set:{"tags.6":data.tags.6 }}
      );
  })
  </code></pre>
  
  <p>it is giving error</p>
  
  <blockquote>
    <p>2014-05-15T08:23:40.161+0100 SyntaxError: Unexpected number</p>
  </blockquote>
  
  <p>Can't I have numbers as the keys ?</p>
  
  <p>Please let me know how to update. </p>