[JAVA-1529] JSON parser allows unmatched trailing quote on field names Created: 03/Nov/14 Updated: 19/Nov/15 Resolved: 19/Nov/15 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | JSON |
| Affects Version/s: | 2.12.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Michael Benoit | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
The JSON parser is a bit too lenient. For example, all these are acceptable:
The first example is what's required by the spec (ie, field names are strings and thus must be surrounded by quotes). The second example is technically illegal but likely in wide use, so that behavior can't change. The third example just looks wrong, but in this case the parser accepts it and assigns a field name of foo". For comparison, here's how the shell handles these cases:
Looks like there may even be a bug in the shell here as well, as I would expect the third document to be printed as:
|
| Comments |
| Comment by Ross Lawley [ 19/Nov/15 ] |
|
In 3.x we have new Json parsers that won't accept this invalid content. In the shape of: BasicDBObject.parse, Document.parse and BsonDocument.parse. As users maybe relying on the current behaviour of JSON.parse I'm marking this as a Won't Fix. |
| Comment by Michael Benoit [ 03/Nov/14 ] |
|
The shell bug mentioned in the description does exist: |