odata-client-php icon indicating copy to clipboard operation
odata-client-php copied to clipboard

Support for large numbers

Open Lych3ster opened this issue 11 months ago • 1 comments

Hi,

I'm trying to consume an Odata service which return big numbers as identifiers. We are talking about numbers 80000000000000000000000 which are represented in by the library in scientific format. I tried to work with casts in the models but this does not really work. When setting the entityReturnType to false and retrieving raw results, I do however get the correct number back. I guess it has to do something with the default casting behavior but until now I did no fund a solution for this issue.

kind regards,

Lych3ster avatar Dec 23 '24 10:12 Lych3ster

After further investigations, it turned out that the json_decode call in the method decodeBody of the class ODataResponse is the problem. If you pass the flag JSON_BIGINT_AS_STRING, the number is formatted correctly.

What needs to be changed is the following line: /*

  • old *$decodedBody = json_decode($this->body, true); */

/*

  • new
  • / $decodedBody = json_decode($this->body, true, 512, JSON_BIGINT_AS_STRING);

I haven't tested out the whole stuff complettly but until now this fixes the problem for me.

Lych3ster avatar Dec 23 '24 15:12 Lych3ster