[CDRIVER-3812] bson_as_json outputs illegal JSON for some locales Created: 02/Nov/20  Updated: 18/Sep/23

Status: Backlog
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Samantha Ritter (Inactive) Assignee: Roberto Sanchez
Resolution: Unresolved Votes: 1
Labels: rb-track
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File locale_test.cpp    
Issue Links:
Duplicate
duplicates CXX-2016 Invalid json value returned Closed
is duplicated by CDRIVER-3938 Rounding errors in double type in bso... Closed
Related
related to CDRIVER-3938 Rounding errors in double type in bso... Closed
Quarter: FY25Q1

 Description   

Many of the bson_as_json visitor functions delegate the work of converting a non-string value to a string to printf (by way of bson_string_append_printf). In certain locales, printf can return strings where a number with a floating point uses a comma instead of a period:

{ "value" : { "$numberDouble" : "1,1000000000000000888" } }

JSON does not accept comma separators in numeric types, only decimal point separators.



 Comments   
Comment by Fermín Galán [ 28/Apr/21 ]

In the case it may be useful, https://jira.mongodb.org/browse/CDRIVER-3938 provides also a way of reproducing it.

 

Comment by Roberto Sanchez [ 23/Dec/20 ]

See attached example for a complete reproducer. This was provided by samantha.ritter.

After some discussion, it seems that the most likely solution is to implement our own serialization function. There is a printf implementation which may serve as a useful reference in our own implementation. It may also be possible to adopt that implementation.

Generated at Wed Feb 07 21:19:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.