title: Store data in Firebase as JSON object
body: <p>So I am working on a small web app and I am using Firebase for the back-end. It's a small chat application and I am trying to store the messages of a person in the following form:</p>
  
  <pre><code>{ "John" : {0: "hello",1:"how are you?".2:"what are you doing?" }}
  </code></pre>
  
  <p>I am storing the person's name in a variable called my_name. My Firebase reference is called ref. Say I set my_name as,</p>
  
  <pre><code>var my_name = "John";
  </code></pre>
  
  <p>and then do</p>
  
  <pre><code>ref.set({my_name : {0:"Hello"}});
  </code></pre>
  
  <p>It stores the data as</p>
  
  <pre><code>{my_name : {0:"Hello"}}
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code>{"John" : {0:"Hello"}}
  </code></pre>
  
  <p>How can I store it so that it uses the assigned value of my_var ?</p>