Git Product home page Git Product logo

Comments (8)

danieleteti avatar danieleteti commented on May 26, 2024

Hi, can you show the code please?

from delphimvcframework.

LairdTurner avatar LairdTurner commented on May 26, 2024

Hi!
Sure...
s := RESTResponse1.Content;
In the string 's' the floating point number is still in there, but if I parse it afterwards with
Obj := TJsonBaseObject.ParseUtf8(s) AS TJsonObject;
and ask for the floating point of the appropriate property
workingHours := Obj['data'].Items[I].F['workingHours'];
I only get for example 2 instead of 2,25?

from delphimvcframework.

LairdTurner avatar LairdTurner commented on May 26, 2024

Any idea!?

from delphimvcframework.

LairdTurner avatar LairdTurner commented on May 26, 2024

Very strange... I ran the compilation on a normal Windows 11. There it works, but on my Mac M2 with Parallels it does not work. It must have something to do with the operating system or Parallels. Any idea?

from delphimvcframework.

danieleteti avatar danieleteti commented on May 26, 2024

Can you post the JSON contained in s?

from delphimvcframework.

LairdTurner avatar LairdTurner commented on May 26, 2024

'{"error":false,"message":"","data":[{"id":101,"personId":4,"date":"2023-10-15T00:00:00Z","allowanceCatalogId":77,"allowanceSurchargeNo":"63","heavy":5,"workingHours":2.5,"createdAt":"2023-10-16T11:30:11Z","updatedAt":"2023-10-16T11:30:11Z"},{"id":102,"personId":4,"date":"2023-10-15T00:00:00Z","allowanceCatalogId":47,"allowanceSurchargeNo":"39","heavy":6,"workingHours":2.5,"createdAt":"2023-10-16T11:32:12Z","updatedAt":"2023-10-16T11:32:12Z"},{"id":105,"personId":4,"date":"2023-10-15T00:00:00Z","allowanceCatalogId":10,"allowanceSurchargeNo":"10","dirt":9,"workingHours":2.25,"createdAt":"2023-10-16T15:00:55Z","updatedAt":"2023-10-16T15:00:55Z"}]}'

from delphimvcframework.

LairdTurner avatar LairdTurner commented on May 26, 2024

It really is a phenomenon. I have compiled the application for OSX ARM 64 and it works without problems. It must have something to do with Windows 11 ARM?

from delphimvcframework.

danieleteti avatar danieleteti commented on May 26, 2024

I don't have a Windows 11 ARM machine, however the following code works as expected in Windows 11 with Win32 and with Win64 target.

uses
  JsonDataObjects;

{$R *.dfm}

procedure TForm13.Button1Click(Sender: TObject);
begin
  var s :=  '{' +
            '    "error": false,' +
            '    "message": "",' +
            '    "data": [{' +
            '            "id": 101,' +
            '            "personId": 4,' +
            '            "date": "2023-10-15T00:00:00Z",' +
            '            "allowanceCatalogId": 77,' +
            '            "allowanceSurchargeNo": "63",' +
            '            "heavy": 5,' +
            '            "workingHours": 2.5,' +
            '            "createdAt": "2023-10-16T11:30:11Z",' +
            '            "updatedAt": "2023-10-16T11:30:11Z"' +
            '        }, {' +
            '            "id": 102,' +
            '            "personId": 4,' +
            '            "date": "2023-10-15T00:00:00Z",' +
            '            "allowanceCatalogId": 47,' +
            '            "allowanceSurchargeNo": "39",' +
            '            "heavy": 6,' +
            '            "workingHours": 2.5,' +
            '            "createdAt": "2023-10-16T11:32:12Z",' +
            '            "updatedAt": "2023-10-16T11:32:12Z"' +
            '        }, {' +
            '            "id": 105,' +
            '            "personId": 4,' +
            '            "date": "2023-10-15T00:00:00Z",' +
            '            "allowanceCatalogId": 10,' +
            '            "allowanceSurchargeNo": "10",' +
            '            "dirt": 9,' +
            '            "workingHours": 2.25,' +
            '            "createdAt": "2023-10-16T15:00:55Z",' +
            '            "updatedAt": "2023-10-16T15:00:55Z"' +
            '        }' +
            '    ]' +
            '}';

  var lObj := TJsonBaseObject.Parse(s) AS TJsonObject;
  try
    var workingHours := lObj['data'].Items[0].F['workingHours'];
    ShowMessage(FloatToStr(workingHours)); // shows 2.5
  finally
    lObj.Free;
  end;
end;

Do you have a different result?

from delphimvcframework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.