Skip to content

Instantly share code, notes, and snippets.

@robertmryan
Last active November 14, 2019 02:02
Show Gist options
  • Save robertmryan/03542e2da539ad7f51c2540bafdad97e to your computer and use it in GitHub Desktop.
Save robertmryan/03542e2da539ad7f51c2540bafdad97e to your computer and use it in GitHub Desktop.
struct Cost: Codable {
let id: String
let label: String
let value: String
}
let cost = Cost(id: "something", label: "something", value: "something")
let jsonData = try! JSONEncoder().encode(cost) // this works fine
let object = try! JSONSerialization.jsonObject(with: jsonData) // this works fine
@MohsenMoghimi
Copy link

MohsenMoghimi commented Nov 13, 2019

in 2 case of web services the response is simple text not a json, something like "the task done", my issue is when I intent to get this responses the " request " function returns myJSONError, how can I modify this class to return a simple string response?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment