1 2 Previous Next 15 Replies Latest reply on Jul 11, 2017 1:54 AM by mrwatson-gbs

    JSONGetElement returns the wrong data type for numbers and booleans

    mrwatson-gbs

      Note: I have already posted this as an idea here, but this must really be logged as an issue, because it is very unexpected behaviour and it WILL lead to bugs in FileMaker databases!

       

      OS and version All

       

      Hardware Whatever

       

      Description

       

      JSONGetElement returns numbers and booleans as text strings.

       

      How to replicate

       

      To see an error situation caused by this bug:

       

      1. Enter in the data viewer:
        1. JSONGetElement ( JSONSetElement ( "" ; "n" ; 45 ; JSONNumber ) ; "n" ) > 9

       

      Expected result: 1 (i.e. true)

      Actual result: 0 (i.e. false)

       

       

       

      Note: To SEE the returned data type, you have to install the MBS plugin, as there is no function to get the data type of a value in FileMaker (see DataType ( data ) function)

       

      1. Install the MBS plugin
      2. Enter in the data viewer:
        1. MBS( "FM.DataType" ; JSONGetElement ( JSONSetElement ( "" ; "n" ; 45 ; JSONNumber ) ; "n" ) )
        2. MBS( "FM.DataType" ; JSONGetElement ( JSONSetElement ( "" ; "n" ; 45 ; JSONBoolean ) ; "n" ) )

       

      Expected result: "number" and "number"

      Actual result: "text" and "text"

       

       

      Workaround

       

      Use GetAsNumber. (<= but nobody wants or expects to have to do that.)

       

      P.S.

       

      If the answer to this post is "This is by design", I would like please also to know what the design goals are of this architecture, thank you.

        1 2 Previous Next