[JAVA-1662] handle control character in Unicode format Created: 25/Feb/15 Updated: 09/Mar/17 Resolved: 09/Mar/17 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | JSON |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | sandip | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
Hi , I have data in such manner:
From Mongo SHELL:
From Java driver when I try this the output is not proper:
The output is :
You can see no data with d . I find that : BasicDBObject.toString call com.mongodb.util.JSON.serialize() to serialize the object to json string. To
From the lines:
this method skip character 0-31, and do not handle control character in Unicode how to handle this kind of unicode data ? |
| Comments |
| Comment by Jeffrey Yemin [ 09/Mar/17 ] | |||
|
This is handled in the 3.x driver using the JsonReader class, which is used by BasicDBObject#toJson. This code, for example:
outputs:
So prefer the toJson method to the toString method and the control characters will be properly output. | |||
| Comment by sandip [ 26/Feb/15 ] | |||
|
Yes , Thank you. | |||
| Comment by Jeffrey Yemin [ 26/Feb/15 ] | |||
|
This issue looks identical to |