panel icon indicating copy to clipboard operation
panel copied to clipboard

Floats are written as Strings in JSON configuration files

Open dr4xor opened this issue 3 weeks ago • 0 comments

Current Behavior

When writing values to a JSON configuration file with the json parser, floats (e.g., 1.5) are being stored as strings ("1.5") in the JSON configuration file instead of as numeric values.

The Game "V Rising" expects floats to have numeric type and fails to load the configuration file because of this.

Expected Behavior

Since the current implementation already correctly handles booleans and integers, storing them as the appropriate types in the JSON file, Float values should be stored as number types in the JSON file too, not as strings.

This is in accordance with RFC 8259 which specifies that JSON numbers can represent both integers and floating-point values. As mentioned the Triple-A Game VRising expects floats to be of type number, so I expect this issue to also affect other games that use JSON configuration files.

Steps to Reproduce

When using Variables like:

BUILD_COST_MODIFIER = 1.5

with the following configuration file

{
    "save-data/Settings/ServerGameSettings.json": {
        "parser": "json",
        "find": {
            ...
            "BuildCostModifier": "{{server.build.env.BUILD_COST_MODIFIER}}",
            ...
        }
    }
}

the resulting ServerGameSettings.json looks like this:

{
    ...
    "BuildCostModifier": "1.5",
    ...
}

and the game (in this case V-Rising) fails to understand the value because it's a string and not a numeric type.

Panel Version

1.11.7

Wings Version

1.11.13

Games and/or Eggs Affected

V-Rising

Docker Image

No response

Error Logs

No response

Is there an existing issue for this?

  • [X] I have searched the existing issues before opening this issue.
  • [X] I have provided all relevant details, including the specific game and Docker images I am using if this issue is related to running a server.
  • [X] I have checked in the Discord server and believe this is a bug with the software, and not a configuration issue with my specific system.

dr4xor avatar Jun 12 '24 19:06 dr4xor