title: Dictionary to JSON being serialised twice in swift 3
body: <p>I'm trying to make a post request with the following dictionary which is converted to JSON</p>
  
  <pre><code>    let store = [
          "newTask" : [
              "project_name": "iOS",
              "total_time":0,
              "color":"blue"
          ]
      ]
  </code></pre>
  
  <p>I am serialising this using the following code and then making a http-POST request using the following options:</p>
  
  <pre><code>        let jsonData = try? JSONSerialization.data(withJSONObject: store)
  
          var request = URLRequest(url: URL(string: "http://localhost:3000/store")!)
          request.httpMethod = "POST"
          request.httpBody = jsonData
  </code></pre>
  
  <p>I am also running a json-server <a href="https://github.com/typicode/json-server" rel="noreferrer">https://github.com/typicode/json-server</a> with the following db.json file </p>
  
  <pre><code>{
   "store": [
    {
      "id": 0,
      "ios": {
        "project_name": "iOS",
        "total_time": 0,
        "color": "blue"
      }
    },
    {
      "id": 1,
      "elm": {
        "project_name": "elm",
        "total_time": 0,
        "color": "blue"
      }
    }
  ]
  }
  </code></pre>
  
  <p>The problem I am having is that the newly added item in the db looks incorrect with the following format:</p>
  
  <pre><code>{
    "{\"newTask\":{\"project_name\":\"iOS\",\"total_time\":0,\"color\":\"blue\"}}": "",
    "id": 10
  },
  </code></pre>
  
  <p>I am unsure as to why it is serialising the whole dictionary as the key and then an empty string as the value. </p>
  
  <p><strong>Update</strong></p>
  
  <p>Here is the code that posts this to the server:</p>
  
  <pre><code>let task = URLSession.shared.dataTask(with: request) { data, response, error in
                  guard let data = data, error == nil else {                                                 // check for fundamental networking error
                      print("error=\(error)")
                      return
                  }
  
                  if let httpStatus = response as? HTTPURLResponse, httpStatus.statusCode != 200 {           // check for http errors
                      print("statusCode should be 200, but is \(httpStatus.statusCode)")
                      print("response = \(response)")
                  }
  
                  do {
                      if let json = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String: Any] {
                          print(json)
  
  
  
                      }
  
                  } catch let error {
                      print(error.localizedDescription)
                  }
  
              }
              task.resume()
  </code></pre>
  
  <p>As a side note, I've tried pining this via postman and it all works <strong>ok</strong>. Attaching a screenshot of it below.
  <a href="https://i.stack.imgur.com/3QKP9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3QKP9.png" alt="enter image description here"></a></p>
  
  <p>Any help will be appreciated, Thanks! </p>