#1 2016-12-27 00:15:53

donaldshimoda
Member
From: Argentina
Registered: 2016-12-09
Posts: 25
Website

How to define the format of float?

I get this JSON value

"TotalVolumen":2567.79126

But the local format use ',' as decimal separator

Then the call to

aFloatvalue := V.TotalVolumen

get an integer

256779126

How to define TdocVariant decimal separator?

Offline

#2 2016-12-27 07:36:21

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

Re: How to define the format of float?

If there is a "," this is not valid JSON...
So there is no way and no mean of changing TDocVariant decimal separator.

Offline

#3 2016-12-27 12:11:51

donaldshimoda
Member
From: Argentina
Registered: 2016-12-09
Posts: 25
Website

Re: How to define the format of float?

ab wrote:

If there is a "," this is not valid JSON...
So there is no way and no mean of changing TDocVariant decimal separator.

Thanks for the response.

The opposite, the float HAVE a '.', is that:

2567.79126

The problem is don´t get recognized as a valid float value.

I have to force this using this code

aTotalVolumen := VarAsType(soVentas.TotalVolumen, varDouble);

I expect to be converted *automagically*

Thanks for any comment or indication of what im doing wrong.

Offline

#4 2016-12-27 12:15:00

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

Re: How to define the format of float?

Use TDocVariantData methods direclty (using e.g. _Safe function) to by-pass late-binding conversions.

Offline

#5 2016-12-27 14:33:42

donaldshimoda
Member
From: Argentina
Registered: 2016-12-09
Posts: 25
Website

Re: How to define the format of float?

I will check it, thanks.

Offline

Board footer

Powered by FluxBB