[JAVA-1358] Support encoding embedded Map within Document Created: 08/Aug/14 Updated: 31/Mar/15 Resolved: 10/Dec/14 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Codecs |
| Affects Version/s: | None |
| Fix Version/s: | 3.0.0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Jeffrey Yemin | Assignee: | Jeffrey Yemin |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Given
and myJson contains a value which is itself a Map, encoding fails:
|
| Comments |
| Comment by Jeffrey Yemin [ 31/Mar/15 ] |
|
Closing all resolved 3.0.0 issues, as 3.0.0 has been tagged and released. |
| Comment by Githook User [ 30/Jan/15 ] |
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: DocumentCodec now encodes and decodes List and Map values |
| Comment by Githook User [ 10/Dec/14 ] |
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: DocumentCodec now encodes and decodes List and Map values |
| Comment by Jeffrey Yemin [ 13/Aug/14 ] |
|
I think we should just do this, as there is no easy workaround |
| Comment by Tim Fox [ 13/Aug/14 ] |
|
I am still struggling with this... Most popular Java JSON libraries represent JSON as Maps. When people are using the MongoDB async Java API it's highly likely that they're going to have their JSON document in the form of a Map and they'll need to convert this to a MongoDB Document in order to use the async Java API, so this should be as simple as possible. Right now I can see no easy way of doing this. In more detail: It works for a simple non nested Map:
Map<String, Object> map = new HashMap(); ^^ This works But for a nested Map Map<String, Object> map = new HashMap(); ^^ This fails What is the correct way (currently) of converting Json in Map form into a document? Cheers |