-
Notifications
You must be signed in to change notification settings - Fork 157
Description
I have the following object:
struct Example: Codable {
var temperature: Double
var latitude: Double
var longitude: Double
}
And an example textual representation:
let example = """
temperature: 3.08
latitude: 40.7580
longitude: -73.9855
"""
I can decode it:
let decoder = YAMLDecoder()
let decodedExample = try decoder.decode(Example.self, from: example)
print(decodedExample)
// Example(temperature: 3.08, latitude: 40.758, longitude: -73.9855)
But when I try to encode it again the doubles all end up in exponential notation:
let encoder = YAMLEncoder()
let encodedExample = try encoder.encode(decodedExample)
print(encodedExample)
// temperature: 3.08e+0
// latitude: 4.0758e+1
// longitude: -7.39855e+1
How can I encode the doubles without the exponential notation?
rogerluan
Metadata
Metadata
Assignees
Labels
No labels