[CXX-532] Converting to json String format has lost back ward compatibility Created: 13/Feb/15 Updated: 17/Jun/15 Resolved: 17/Jun/15 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | BSON |
| Affects Version/s: | legacy-0.0-26compat-2.6.7 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | NagavelpandiK | Assignee: | Andrew Morrow (Inactive) |
| Resolution: | Incomplete | Votes: | 0 |
| Labels: | legacy-cxx | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
While using mongo2.2, got bson and converted to jsonString using the api provided, I upgraded my driver to use mongo2.6, The json format returned do not match with the existing json format. mong2.6 : {"myData" : {$numberLong : 1}} Please provide us an solution. |
| Comments |
| Comment by Andrew Morrow (Inactive) [ 17/Jun/15 ] |
|
Closing as 'incomplete' because there is still not a clear description of the expected vs actual output, or example code that demonstrates the problem. Feel free to re-open if you have time to provide the information we are requesting. |
| Comment by Andrew Morrow (Inactive) [ 11/Jun/15 ] |
|
Hi nagavpk - Could you please provide a complete (compilable and runnable) example that shows what you want to do, and then what the expected and actual outputs are? I think that would help us move this ticket towards a resolution. Also, could you you please describe which version of the driver you were using when you got the output you desired and how you obtained that driver, and which driver you are using now, when you get the undesired output? |
| Comment by NagavelpandiK [ 30/Apr/15 ] |
|
I am sorry i did not reply you, I used legacy driver with JsonStringFormat::JS as argument but no change in response |
| Comment by Adam Midvidy [ 01/Apr/15 ] |
|
Hi nagavpk - I am going to close this ticket. If you need further help, let me know and I will reopen it. |
| Comment by Adam Midvidy [ 31/Mar/15 ] |
|
nagavpk did the above solution work for you? |
| Comment by Adam Midvidy [ 25/Mar/15 ] |
|
Hi nagavpk, the above solution of using JsonStringFormat::JS should work with the legacy driver. I am assuming that is what you mean by "mongo3 driver". Adam |
| Comment by NagavelpandiK [ 17/Mar/15 ] |
|
Hi, |
| Comment by Tyler Brock [ 25/Feb/15 ] |
|
Oh, that should be relatively easy to resolve. In your application's request handler just use mongo::JsonStringFormat::JS as the format when calling tojson in order to craft the response to the client: http://api.mongodb.org/cxx/legacy-1.0.0/namespacemongo.html#ad907608317d02cc29dab225747bd791b |
| Comment by NagavelpandiK [ 25/Feb/15 ] |
|
Tyler Brock, . I query the user details as BSON converted to jsonString using toJsonStrong function then sent it to browser; I have got the value of id as double. But now mongo2.6 returns {id : {$double : 1}}, How shall i parse this in browser. Should we modify the application client js for this? If that is the case, I have to change in hundred places. My problem is the json format is not returned as available in mongo2.2 not {id : {$double : 1}}) Thanks, |
| Comment by Tyler Brock [ 24/Feb/15 ] |
|
NagavelpandiK, If I understand the scenario you described correctly it seems like the newer 2.6 version has actually gained round-trip ability. Before, no matter what type the number mydata was originally it would always be re-serialized into BSON as a a double. The newer version encodes the type information as extended JSON as a 64 bit integer (number long) so that you don't loose the type information. You should be able use the mongo::fromjson() function to get it back into BSONObj form: http://api.mongodb.org/cxx/current/namespacemongo.html#a6afa47c3e31b0942d21af793f02715b2 If I did not understand correctly it would be very helpful if you could distill the problematic code into a self contained working example (without any omissions) so that I can try to definitively resolve the issue for you. |
| Comment by Andrew Morrow (Inactive) [ 16/Feb/15 ] |
|
nagavpk RE building legacy-1.0.0 with boost 1.47. Officially, our minimum required boost is 1.49. However, in practice, we would expect it to build with older boost versions, maybe back to 1.41 or so. Could you provide some additional details on what errors you get when building the legacy driver against boost 1.47? If is is an easy fix we will try to apply it for our next patch release. Thanks, |
| Comment by NagavelpandiK [ 16/Feb/15 ] |
|
Hi Tyler Brock, I have stored the details of an user in mongodb, while logging-in I query the db and directly send the details to the browser. The code is : std::string myService(.....){ And Could we build legacy-1.0.0 driver using boost version 1.47. Thanks for replying |
| Comment by Tyler Brock [ 13/Feb/15 ] |
|
Hey NagavelpandiK, If you are moving to a new version of the driver we highly suggest you move to the legacy-1.0.0 driver rather than 26compat. Can you provide us with a snippet of the code that you are having trouble with? (preferably in a github gist or something of that sort) |