title: firestore -- Add element in a field in hashmap
body: <p><a href="https://i.stack.imgur.com/B9Nck.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B9Nck.png" alt="enter image description here"></a></p>
  
  <p>Above is the structure of collection "networks". What is want to do is add another element in "users" field. It's a <code>HashMap</code>. I want to achieve is Key= xyz@gmail.com and its values {displayName: "Anirudh Kumar", "role":"admin"}.</p>
  
  <p>xyz@gmail.com
      displayName: "Anirudh Kumar"
      role: "admin"</p>
  
  <p>I have tried few things but it doesn't seems to work.</p>
  
  <p>1st option</p>
  
  <pre><code>        Map&lt;String, Network.NetworkUser&gt; users = new HashMap&lt;&gt;();
          users.put(email, networkUser);
  
         db.collection("networks").document("id")
            .update("users",FieldValue.arrayUnion(users));
  </code></pre>
  
  <p>2nd option</p>
  
  <pre><code>       db.collection("networks").document(userNetwork.getNetworkUid())
                                  .set(users,SetOptions.merge());
  </code></pre>
  
  <p>3rd option</p>
  
  <pre><code>                            db.collection("networks").document(userNetwork.getNetworkUid())
                                  .update("users."+email,networkUser);
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/XYRhP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XYRhP.png" alt="enter image description here"></a></p>
  
  <p>3rd option takes me closer to answer, but because of dot [.] in an email it creates another row, let me know if somehow this can be avoided.</p>
  
  <p>If anyone can assist me how can I achieve the desired goal, it would be appreciated. Thanks.</p>