title: react-native: how can I convert output of Object.assign to a valid json format?
body: <pre><code>constructor(props) {
      super(props);
      this.state =
      {
        selectedDropDownValue:[]
      };
    }
  
  func(itemName,itemValue)
        this.setState({
            selectedDropDownValue: Object.assign(this.state.selectedDropDownValue, {[itemName]: itemValue})
        });
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>func("size",null);
  func("color","white");
  </code></pre>
  
  <p>when I logged it, I get somthing like this:</p>
  
  <pre><code>console.log(this.state.selectedDropDownValue);
  </code></pre>
  
  <blockquote>
    <p>[size: null, color: "white"]</p>
  </blockquote>
  
  <p>I want something like this:</p>
  
  <blockquote>
    <p>{"size": null, "color": "white"}</p>
  </blockquote>
  
  <p>I want to send it to a PHP server, But it is not a valid JSON code.</p>
  
  <p>how can I convert it to a JSON format before sending it to the server?</p>