Davide Angeli 46 Posted October 2 I have a problem that's driving me crazy. I'm using ISuperObject to store in a JSON string a series of complex (non-tabular) data in a Firebird memo field. Within this JSON, some numerical data with two decimal places (which are currency type variables in Delphi) is being stored. In a couple of cases (which I unfortunately can't replicate myself with the same values), some of my customers, upon saving this data, ended up with more than two decimal places in the resulting JSON (for example, 2332.89 became 2332.889xxxx). I'm using the ISuperObject property like this O.F['namevar']:=currencyvalue to insert the data into the JSON. Do you think it's possible that the behavior of ISuperObject might vary on certain computers, leading to the problem I've encountered? Share this post Link to post
Vincent Parrett 909 Posted October 2 In my experience this will be due to Locale differences - does superobject use FormatSettings at all? Share this post Link to post
Davide Angeli 46 Posted October 2 13 minutes ago, Vincent Parrett said: In my experience this will be due to Locale differences - does superobject use FormatSettings at all? procedure TJSONFloat.AsJSONString(Str: TJSONWriter); begin if FNull then Str.AppendVal( cNull ) else Str.AppendVal( FloatToStr(Value, FloatFormat) ); end; Share this post Link to post
Davide Angeli 46 Posted October 2 Just now, Vincent Parrett said: What is FloatFormat set to? const FloatFormat : TFormatSettings = ( DecimalSeparator : '.' ); Share this post Link to post
Stefan Glienke 2190 Posted October 2 If it is currency, then FloatToStr is wrong to begin with Share this post Link to post
Davide Angeli 46 Posted October 2 1 minute ago, Stefan Glienke said: If it is currency, then FloatToStr is wrong to begin with I agree. Unfortunately, ISuperObject does not support the direct insertion of currency type data. Share this post Link to post
Davide Angeli 46 Posted October 2 6 minutes ago, Olli73 said: Use latest version and then try I'm using this one: https://github.com/onryldz/x-superobject, latest changes are 5 years ago... I don't see an O.C[] property in this one. Is there another version available somewhere? Share this post Link to post
Olli73 8 Posted October 2 https://github.com/pult/superobject.delphi v1.2 support of currency data type 1 Share this post Link to post
Davide Angeli 46 Posted October 2 It's not the same library but seems quite similar... Share this post Link to post
Angus Robertson 690 Posted Thursday at 10:23 AM The ICS component library includes a fork of SuperObject, with various bug features and new features, including returning parsing errors and support for Delphi TDateTime, saved as an ISO 8601/RFC3339 string: obj.AsDateTime, obj.AsObject.DT['foo'] https://svn.overbyte.be/svn/icsv9/Source/OverbyteIcsSuperObject.pas I could add a currency type if useful. . Angus 1 Share this post Link to post
Davide Angeli 46 Posted Thursday at 11:39 AM 1 hour ago, Angus Robertson said: I could add a currency type if useful. . it seems to already be there... Share this post Link to post
Angus Robertson 690 Posted Thursday at 12:01 PM That's convenient, never used it myself... I did fix a problem with floats variously using . and , which is a no-no in Json. Angus Share this post Link to post