jsonvisual-foxprochilkat

Chilkat json outputs decimal numbers with comma


In chilkat activeX (my version: 9.5.0.86), when I create object with numeric property .emit() method returns JSON string with number where decimal part is separated with comma. This depends on my regional settings here in Control panel. But this shouldn't be dependent on this, because this JSON RFC: https://www.ietf.org/rfc/rfc4627.txt says that numbers must always be separated by dot.

This code (in VFP)

oJson = CreateObject('Chilkat_9_5_0.JsonObject')
oJson.AddNumberAt(-1,"test1", 12.3)
?oJson.Emit()

when I have set comma in settings, output of this code is: {"test1":12,3}

and when I have set dot, output is: {"test1":12.3}

Is there a way how to setup chilkat, to always get numbers with dot? It seems, that problem is with method AddNumberAt, because when I get json with load method


Solution

  • The 2nd argument to UpdateNumber should be a string. See https://chilkatsoft.com/refdoc/xChilkatJsonObjectRef.html#method81

    You passed a floating point number, which was coerced into a string by your programming language, and the coercion is what caused the comma to be used.