Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsonEncodedString not deal Date type #271

Open
zyy13579 opened this issue Nov 1, 2018 · 3 comments
Open

jsonEncodedString not deal Date type #271

zyy13579 opened this issue Nov 1, 2018 · 3 comments

Comments

@zyy13579
Copy link

zyy13579 commented Nov 1, 2018

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

@kuhl
Copy link

kuhl commented Nov 16, 2018

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

@LeeCenY
Copy link

LeeCenY commented Nov 19, 2018

It is recommended to use the String type

@kuhl
Copy link

kuhl commented Nov 19, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants