Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2016-05

TJSONboolean and locale settings

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

Is TJSONboolean, and it’s internal BoolToStr(AValue, True) and StrToBool() calls, affected by locale settings?

For example:
My locale is en_GB and I store a Boolean (True) value to a JSON file, which results in a string value “True”. If I now read that JSON file on a system with locale af_ZA (Afrikaans, or any other non-English language for that matter) - would it still work?

Regards,
Graeme

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote
Hi, Is TJSONboolean, and it’s internal BoolToStr(AValue, True) and StrToBool() calls, affected by locale settings?

GetAsString is.

Show quoted text 6 lines
For example: My locale is en_GB and I store a Boolean (True) value to a JSON file, which results in a string value “True”. If I now read that JSON file on a system with locale af_ZA (Afrikaans, or any other non-English language for that matter) - would it still work?

Yes, because 'GetAsJSON' is not dependent on locale, but returns hardcoded values.

function TJSONBoolean.GetAsJSON: TJSONStringType;
begin
   If FValue then
     Result:='true'
   else
     Result:='false';
end;

Michael.

Graeme Geldenhuys
to Michael Van Canneyt
Michael Van Canneyt wrote
Yes, because 'GetAsJSON' is not dependent on locale, but returns hardcoded values.

OK, thanks for clarifying that for FPC.

So does the JSON Standard define saved boolean values as hard-coded English “True” and “False” values, no matter the locale?

Regards,
Graeme

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 8 lines
On 2016-05-13 15:05, Michael Van Canneyt wrote: > Yes, because 'GetAsJSON' is not dependent on locale, but returns hardcoded > values. OK, thanks for clarifying that for FPC. So does the JSON Standard define saved boolean values as hard-coded English “True” and “False” values, no matter the locale?

Yes. They are Javascript true and false; they are keywords.

Michael.