Closed coder-free closed 3 years ago
Its because the values actual type from JSONSerialization.jsonObject
is a Double
, not a Float
. Runtime will not auto convert any type for. You would need to convert it manually before setting it:
if let property = try? info.property(named: key) {
if value is Double {
try? property.set(value: Float(value), on: &bean)
} else {
try? property.set(value: value, on: &bean)
}
}
@wickwirew ok, thank you
got log:
Set
Floating
value toDouble
success. SetFloating
value toFloat
fail.