#1 2016-01-23 21:25:57

Sebo
Member
Registered: 2016-01-23
Posts: 2

Comma as decimal point in regional settings and invalid JSON

Hello

There is a problem with JSON generated by VariantSaveJSON when user changed decimal point to comma for English(United States) format in regional settings window.
In this case TTextWriter.AddDouble produces text with comma what makes JSON invalid.

procedure TForm1.FormShow(Sender: TObject);
var
  V: variant;
begin
  TDocVariant.New(V);
  V.num := 1.123456;
  Memo1.Lines.Add(VariantSaveJSON(v));
end;

The output is:

{"num":1,123456}

The solution is to add:

SettingsUS.DecimalSeparator := '.';

in SynCommons.InitSynCommonsConversionTables after SettingsUS initialization.

Offline

#2 2016-01-23 22:08:37

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Comma as decimal point in regional settings and invalid JSON

It has been fixed by http://synopse.info/fossil/info/d8fffde213

Thanks for the report!

Offline

Board footer

Powered by FluxBB