Perfect icon indicating copy to clipboard operation
Perfect copied to clipboard

jsonEncodedString not deal Date type

Open zyy13579 opened this issue 7 years ago • 3 comments

The jsonEncodedString not convert Date type,that make response by json with date type will fail. like this code will return fail to js client response.setHeader(.contentType, value: "application/json") let d: [String:Any] = ["a":1, "b":0.1, "c": true, "d":[2, 4, 5, 7, 8],"f":Date()] do{ try response.setBody(json: d) }catch{

}
response.completed()

Hope add Date type convert in jsonEncodedString

zyy13579 avatar Nov 01 '18 09:11 zyy13579

@kjessup Are you keeping jsonEncodedString in it's current form or are you going to implement Foundation's JSONEncoder everywhere?

kuhl avatar Nov 16 '18 16:11 kuhl

It is recommended to use the String type

LeeCenY avatar Nov 19 '18 02:11 LeeCenY

It's not an issue of whether converted to a String. The issue is a feature request to automatically handle the Date type.

kuhl avatar Nov 19 '18 17:11 kuhl