WebApi icon indicating copy to clipboard operation
WebApi copied to clipboard

Add parameter IEEE754Compatible for input/output json mediaType.

Open biaol-odata opened this issue 7 years ago • 4 comments

Issues

This pull request fixes issue #1460.

Description

Made IEEE754Compatable parameter available to input/output ODataFormattere's supported Json media types. Default value is false, i.e. Int64 and Decimal numbers are not represented as strings. Added to both AspNet.OData and AspNetCore.OData.

Checklist (Uncheck if it is not completed)

  • [x] Test cases added
  • [x] Build and test with one-click build and test script passed

Additional work necessary

If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.

biaol-odata avatar Jun 22 '18 00:06 biaol-odata

Since IEEE754Compatible defaults to false, the only time someone would care about it would be if they needed int64 returned as string (in which case, they would explicitly set it to true). There's really not much point in advertising the ability to set it to true.

So, can we remove all of the IEEE754Compatible=false cases, and only advertise the default (i.e., no IEEE754Compatible) and the option to explicitly set it to true? I think the code will also support explicitly setting to false, regardless of what we advertise, but there's no reason to advertise that option and removing it reduces the number of combinations by 1/3.

Similarly, I don't think there's any value in advertising streaming=false. If we remove all of the streaming=false options that would allow us to further reduce the list by more than half. #ByDesign

mikepizzo avatar Jun 27 '18 00:06 mikepizzo

Note in ODataMediaTypesTest.cs, there are unit tests for each value which should be added for the new IEEE754Compatible media types. i.e.:

    [Fact]
    public void ApplicationJsonIEEE754CompatibleTrue_Value()
    {
        Assert.Equal("application/json;IEEE754Compatible=true",
            ODataMediaTypes.ApplicationJsonIEEE754CompatibleTrueToString());
    }

etc... #Resolved

mikepizzo avatar Jun 27 '18 00:06 mikepizzo

The overall pattern of ODataMediaTypes is to list the parameter w/ values explicitly as well as no values. For example, for the case of 'odata.streaming': public static readonly string ApplicationJsonODataFullMetadata = "application/json;odata.metadata=full"; public static readonly string ApplicationJsonODataFullMetadataStreamingFalse = "application/json;odata.metadata=full;odata.streaming=false"; public static readonly string ApplicationJsonODataFullMetadataStreamingTrue = "application/json;odata.metadata=full;odata.streaming=true"; This enables the resolution of various content-type headers in the requests.


In reply to: 400506979 [](ancestors = 400506979)

biaol-odata avatar Jun 27 '18 05:06 biaol-odata

Are there any news or plans, when IEEE754Compatible=true will be supported ?

Right now, I can't load values as String if I add an "Accept: application/json;IEEE754Compatible=true"

ckuetbach avatar Jul 31 '20 11:07 ckuetbach