title: Xcode invalid top level type in JSON write
body: <p>Code:</p>
  
  <pre><code>    apiError(ios_service.GGAPIErrorMessage(json: {
          "register" : {
            "data" : {
              "fields" : [
               {
                  "name" : "token",
                  "value" : "zlS4OJxoskpvpXfdD9bE8zwjLjitqE"
               }],
               "params" : []
            },
          }
      }
  
  
  
  do {
      let jsonObject = try JSONSerialization.data(withJSONObject: error, options: .prettyPrinted)
      print("jsonObject:\(jsonObject)")
  } catch let error {
      print("error:\(error)")
  }
  </code></pre>
  
  <p>Exception:</p>
  
  <blockquote>
    <p>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSJSONSerialization dataWithJSONObject:options:error:]: Invalid top-level type in JSON write</p>
  </blockquote>
  
  <p>I need to handle error response from server. I shared my JSON parsing code.</p>