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

Issue: try to use JsonConverter.ConvertToJson fuction to convert,but String value becomes Integer #270

Open
Douglas87 opened this issue May 11, 2024 · 1 comment

Comments

@Douglas87
Copy link

I want to convert a Json bject to String,so I used JsonConverter.ConvertToJson fuction

my test case Json object is {"stringKey":"2024051090001075"}
after use JsonConverter.ConvertToJson, my expect str is {"stringKey":"2024051090001075"}, but got {"stringKey":2024051090001075}

@Douglas87 Douglas87 changed the title Issue: try to use JsonConverter.ConvertToJson fuction to convert,but String value becomes Intergret Integer Issue: try to use JsonConverter.ConvertToJson fuction to convert,but String value becomes Integer May 11, 2024
@Nick-vanGemeren
Copy link

' VBA only stores 15 significant digits, so any numbers larger than that are truncated
' This can lead to issues when BIGINT's are used (e.g. for Ids or Credit Cards),
' as they will be invalid above 15 digits
' See: http://support.microsoft.com/kb/269370
'
' By default, VBA-JSON will use String for numbers longer than 15 characters that
' contain only digits
' to override set JsonConverter.JsonOptions.UseDoubleForLargeNumbers = True

The option description applies to parsing from a JSON string. But for consistency the equivalent actions are used in the other direction when converting to JSON.

So counter-intuitively (since you aren't using Double), to keep your string value, make the option True before calling ConvertToJson.

================
If the above solves your problem, please close the issue here.

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