Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative numbers not converted to string correctly #5

Closed
dpbevin opened this issue Mar 17, 2020 · 4 comments
Closed

Negative numbers not converted to string correctly #5

dpbevin opened this issue Mar 17, 2020 · 4 comments

Comments

@dpbevin
Copy link
Contributor

dpbevin commented Mar 17, 2020

I tried running one of the DBS specs (account-presentation-spec) through the converter and found that yaml validation failed on negative numbers in an example. If you look in the arrangements-with-balance-history-ex.json file, there's a section that looks like this:

        {
          "dateFrom": "2017-06-12T00:00:00.000Z",
          "dateTo": "2017-07-01T00:00:00.000Z",
          "value": {
            "currency": "EUR",
            "balance": "4"
          },
          "valuePtc": "4"
        },
        {
          "dateFrom": "2017-06-18T00:00:00.000Z",
          "dateTo": "2017-07-01T00:00:00.000Z",
          "value": {
            "currency": "EUR",
            "balance": "-14"
          },
          "valuePtc": "-14"
        }

It is the valuePtc at the bottom (set to "-14") that gets generated to yaml as this:

  - dateFrom: 2017-06-12T00:00:00.000Z
    dateTo: 2017-07-01T00:00:00.000Z
    value:
      currency: EUR
      balance: "4"
    valuePtc: "4"
  - dateFrom: 2017-06-18T00:00:00.000Z
    dateTo: 2017-07-01T00:00:00.000Z
    value:
      currency: EUR
      balance: -14
    valuePtc: -14

You can see the difference between between "4" and -14.

I debugged the code and tracked it down to the Jackson YAML library (jackson-dataformat-yaml) that's used to generate the YAML.

The regex that's used to determine the quote rules doesn't handle negative numbers correctly. See https://github.com/FasterXML/jackson-dataformats-text/blob/d69291651114b9e7a2ccbe1a3a154f2b84f95b30/yaml/src/main/java/com/fasterxml/jackson/dataformat/yaml/YAMLGenerator.java#L175

I'm working on a PR for the Jackson library and will link here once submitted.

@dpbevin
Copy link
Contributor Author

dpbevin commented Mar 17, 2020

Root cause raised in Jackson YAML library: FasterXML/jackson-dataformats-text#182.

PR raises for 2.10.x branch: FasterXML/jackson-dataformats-text#183

@bartveenstra
Copy link
Contributor

Excellent find @dpbevin . Let us hope that jackson merges that PR quickly so we can update to the latest version. If this is going to take too long, we could try to switch to SnakeYaml

@dpbevin
Copy link
Contributor Author

dpbevin commented Mar 17, 2020

The fix has been applied to Jackson. We now just need to wait for a new package to be generated.

@bartveenstra
Copy link
Contributor

Closed by upgrading jackson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants