0

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

VladoS
  • 13
  • 3

1 Answers1

1

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.

Chilkat Software
  • 1,405
  • 1
  • 9
  • 8
  • why would a coercion cause comma to be used? How it is dependent on the programming language it is used. Where did you see the programming language forcing a comma? Documentation says "AddNumberAt(ByVal index As Long, name As String, numericStr As String) As Long" which is rather weird to use a string for a numeric. – Cetin Basoz Apr 20 '21 at 11:30