Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@fitomad
Created December 3, 2018 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fitomad/f2f60dcadccd912a9a1a3060e2b08f7f to your computer and use it in GitHub Desktop.
Save fitomad/f2f60dcadccd912a9a1a3060e2b08f7f to your computer and use it in GitHub Desktop.
/**
Corrige el formato del JSON proviniente del API
de BiciMAD.
Parece que la clave `data` incluye el caracter backslash `\`,
al igual que las llaves de apertura `{` y cierre `}`
- Parameter data: El stream de datos devuelto por el servicio
- Returns: El stream con un formato `JSON` válido
*/
private func fixJSONResponse(from data: Data) -> Data?
{
guard var jsonResponse = String(data: data, encoding: .utf8) else
{
return nil
}
...
return jsonResponse.data(using: .utf8)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment