title: Serialize floats to JSON in Swift without dropping decimal
body: <p>Scenario: I have a schemaless database API that infers type based on json passed into it. Once the database infers schema however, all subsequent entries added to the same table must follow the existing schema. I'm pushing json-formatted data to a REST endpoint from my Swift app.</p>
  
  <p>I'm using <a href="https://github.com/Hearst-DD/ObjectMapper" rel="nofollow noreferrer">ObjectMapper</a> to define schema/serialization for data within the Swift app, e.g.:</p>
  
  <pre><code>class ExampleDatum: Mappable {
  
      value: Float?
  
      init() {
      }
  
      required init?(map: Map) {
      }
  
      func mapping(map: Map) {
          value &lt;- map["value"]
      }
  }
  </code></pre>
  
  <p>The issue comes that if value is a whole number, json is formatted without the decimal point, leading to inconsistent interpretation of this field as an integer/float:</p>
  
  <pre><code>let datum = ExampleDatum()
  datum.value = 5.0
  print(datum.toJSONString())
  &gt;&gt; {"value": 5}
  </code></pre>
  
  <p>What's the best practice to embed this type information in JSON, e.g. to enforce the decimal point always be included? Ideally something like <code>{"value": 5.0}</code></p>