I am writing some Float values to a json file. Since I need the values in json as it is, example, 1.2 as 1.2, I am declaring the values as Decimal type.

    let value: Decimal = 1.2
    let dictionary: [String: Any] = ["key1": "value", "key2": value]
    do {
        let fileURL = try FileManager.default
            .url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true)

        try JSONSerialization.data(withJSONObject: dictionary)
            .write(to: fileURL)
    } catch {

Above code writes json file as {"key1":"value","key2":1.2} which is expected.

When I try to write values like 1.0 or 2.0, numbers with decimal point zero, the decimal point is seen ignored in the json. It is just written as 1 and 2. But I want them as 1.0 and 2.0 in the json. What is missing in the code?