BeamMP / BeamMP-Server

Server for the multiplayer mod BeamMP for BeamNG.drive
https://beammp.com
GNU Affero General Public License v3.0
116 stars 49 forks source link

Util.JsonDecode fails when trying to decode JSON with -Infinity values #249

Closed 5TXdYWK closed 5 months ago

5TXdYWK commented 6 months ago

Fill out general information BeamMP-Server Version: 3.2.0L

Describe the bug Trying to decode the following file will cause an error: RP_TurdieV8-_Broken.json This file is valid JSON and can be parsed in Javascript, for example.

To Reproduce Steps to reproduce the behavior:

  1. Call Util.JsonDecode(thisFile)
  2. Receive [LUA ERROR] string given to JsonDecode is not valid json:

Expected behavior It should parse the JSON regardless of the -Inf values.

lionkor commented 5 months ago

That's not -Inf, that's -9e999. That's a completely different problem, since it should be able to handle -inf.

lionkor commented 5 months ago

As nlohmann json handles -infinity, but throws out-of-range exceptions when the number doesn't fit in double

lionkor commented 5 months ago

Javascript can do this fine, but sadly we can't fix this easily, as it means we'd need to parse the json manually and replace any values > double max with infinity, and so on. Please try replacing these values with null manually, if you encounter this