[JAVA-280] BSONTimestamp and some other fields are not properly serialized to JSON and cannot be parsed back Created: 23/Feb/11 Updated: 19/Oct/16 Resolved: 25/Apr/11 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | None |
| Affects Version/s: | 2.4 |
| Fix Version/s: | 2.5.3 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Ryan Nitz | Assignee: | Antoine Girbal |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
Calling toString() on a BSON object that has a BSONTimestamp field, yields a display of: "start" : 1298475384|324 |
| Comments |
| Comment by auto [ 29/Mar/11 ] |
|
Author: {u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}Message: |
| Comment by auto [ 22/Mar/11 ] |
|
Author: {u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}Message: |
| Comment by auto [ 19/Mar/11 ] |
|
Author: {u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}Message: |
| Comment by Antoine Girbal [ 18/Mar/11 ] |
|
After the fix, the following document is properly parsed from json, inserted in db, read from db, serialized into json: { , , , , , Notes:
Let me know if sounds ok and I'll commit. |
| Comment by Antoine Girbal [ 17/Mar/11 ] |
|
Here are most types we support: , , , , I guess I'll fix so that whatever is serialized can be parsed, besides Binary. |
| Comment by Antoine Girbal [ 17/Mar/11 ] |
|
Also, it's kind of bad that you cannot do mongoexport / mongoimport and get things identical foo:PRIMARY> db.accounts.insert( {a: Timestamp()}) } $ ./mongoexport -d testdb -c accounts | ./mongoimport -d testdb -c accounts2 foo:PRIMARY> db.accounts2.find() } For all native bson types, we should make sure they can be exported/imported in JSON reliably. |
| Comment by Antoine Girbal [ 17/Mar/11 ] |
|
As other example, regexp is like: { "$regex" : ".*" , "$options" : ""} |
| Comment by Antoine Girbal [ 17/Mar/11 ] |
|
so there are 2 ways the timestamp is represented today:
when doing dbobject.toString(), it will call the JSON.serialize. If you look in shell, a timestamp is represented by an object with no easy way to tell it's a timestamp: { "field" : { "t" : 0, "i" : 0 }} So I think the format should be either:
|
| Comment by Ryan Nitz [ 17/Mar/11 ] |
|
Nod... they recommend using either commas or decimal points for fractions. |
| Comment by Scott Hernandez (Inactive) [ 17/Mar/11 ] |
|
That won't display the increment part though, will it? Sometimes it is very useful to see that when looking at a bunch from the same second. What about Timestamp("<iso string>", ###)? We could make this universal with javascript and other drivers. |
| Comment by Ryan Nitz [ 16/Mar/11 ] |
|
How about using the ISO 8601 format? |
| Comment by Eliot Horowitz (Inactive) [ 26/Feb/11 ] |
|
Any suggestions on the correct display? |