[SERVER-9414] mongo::fromjson failed Created: 20/Apr/13  Updated: 07/Apr/23  Resolved: 24/Apr/13

Status: Closed
Project: Core Server
Component/s: Internal Client
Affects Version/s: 2.4.1, 2.4.2
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Frédéric Logier Assignee: Shaun Verch
Resolution: Done Votes: 0
Labels: driver
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux


Attachments: File reproduction.cpp    
Operating System: ALL
Steps To Reproduce:

string json = "

{ \"A\": 1, \"B\":2 }

";
BSONObj test = mongo::fromjson(json);
failed with this exception :
code FailedToParse: FailedToParse: Expecting '}' or ',': offset:9

string json = "

{ \"A\": 1 , \"B\":2 }

";
with the white space after 1, it works.

Participants:

 Description   

mongo::fromjson is failed if there is no white space before comma when the value is an int.



 Comments   
Comment by Thomas Renoth [ 12/Sep/13 ]

This has to do with fromjson using strtod which parses numbers based on the system locale. If your locale (de_DE.UTF-8 in my case) happens to use a comma as decimal separator you end up with this error. Oddly enough I haven't managed to reproduce this with a plain cpp file; it only happens in a Qt project we have. A workaround is to change LC_NUMERIC to a locale that does not use a comma as decimal separator.

Comment by Shaun Verch [ 24/Apr/13 ]

Hi Fred,

Thanks for the response. I'll go ahead and close the ticket for now. If there's any way we could help further to diagnose the cause of this issue feel free to let us know!

Thanks!
~Shaun Verch

Comment by Frédéric Logier [ 24/Apr/13 ]

Hi Shaun,
I can't reproduce the error with the test code, so I suppose that it's a
weird side effect in my application ... You can close the ticket.

2013/4/23 Shaun Verch (JIRA) <jira@mongodb.org>


http://fredix.wordpress.com

Comment by Shaun Verch [ 23/Apr/13 ]

Hi Frédéric,

I wasn't able to reproduce this either in our unit tests for the json parser or in a small C++ application. Could you attach a file to this ticket containing a small example that fails? I've attached the test code I used that works with the 2.4.1 and 2.4.2 versions of the C++ driver.

Thanks,
~Shaun Verch

Generated at Thu Feb 08 03:20:20 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.