Fleece icon indicating copy to clipboard operation
Fleece copied to clipboard

JNumber

Open wallymathieu opened this issue 7 years ago • 1 comments

Fleece.fs#L117-L118 (Newtonsoft.Json):

        | JTokenType.Integer -> JNumber  o
        | JTokenType.Float   -> JNumber  o

Where o is JsonValue

Fleece.fs#L223-L224 (FSharp.Data):

        | JsonValue.Number _ as x -> JNumber x
        | JsonValue.Float _ as x  -> JNumber x

Where x is JsonValue

While for System Json there doesn't seem to be such a distinction.

The function JNumber takes a decimal as parameter. It would make sense to be able to use float as well.

wallymathieu avatar Sep 25 '18 05:09 wallymathieu

To get better type safety for Newtonsoft.Json and FSharp.Data perhaps it would help to add a structure:

    [<Struct>]
    type FleeceNumeric = 
        | Long of long:int64
        | Decimal of decimal:decimal
        | Float of float:float  

in order to be able to retain the information of the active pattern?

wallymathieu avatar Sep 25 '18 05:09 wallymathieu