title: iOS Swift:"JSON text did not start with array or object and option to allow fragments not set."
body: <p>When I converting Json string to dictionary in swift I got the Issue:<strong>Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}</strong></p>
  
  <p>I don't know to fix the issue please give idea for fix the issue.Here I gave my code what i am tried..</p>
  
  <p>The method for converting Json string to dictionary is,</p>
  
  <pre><code>func convertToDictionary(from text: String) throws -&gt; [String: String] {
      guard let data = text.data(using: .utf8) else { return [:] }
      let anyResult: Any = try JSONSerialization.jsonObject(with: data, options: [])
      return anyResult as? [String: String] ?? [:]
  }
  </code></pre>
  
  <p>The Json String is: <code>"[{\"propertyId\":\"1\",\"inspectionTemplateId\":1118,\"value\":[{\"widgetControllerId\":141,\"value\":\"Flood Summary Name\"},{\"widgetControllerId\":142,\"value\":\"Did the property flood?\"},{\"widgetControllerId\":143,\"value\":\"no\"}]}]"</code></p>
  
  <p>And the Usage of method was:</p>
  
  <pre><code>let jsonString = NSString(data: responseObject as! Data, encoding: String.Encoding.utf8.rawValue)!
          print(jsonString)
          do {
              let dictionary:NSDictionary = try self.convertToDictionary(from: jsonString as String) as NSDictionary
              print(dictionary)
          } catch {
              print(error)
          }
  </code></pre>