[JAVA-3105] Following the RFC, Position should be a list of double, not an object containing a list of double Created: 30/Nov/18 Updated: 27/Oct/23 Resolved: 11/Jan/19 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Codecs |
| Affects Version/s: | 3.9.1 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Julien Deruere | Assignee: | Unassigned |
| Resolution: | Gone away | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
When decoding a Geometry, I end up having this structure from Mongo Geometry codecs:
When I more expecting this:
Following the RFC: https://tools.ietf.org/html/rfc7946#section-3.1.1 |
| Comments |
| Comment by Jeffrey Yemin [ 01/Dec/18 ] | ||||||||||||||||||||||||||||||||||
|
You're using Jackson to encode the driver's Geometry POJO's to JSON, but those POJOs don't have Jackson annotations. So, for example, the LineString class contains the field List<Position> values, and the Position class contains the field List<Double> values. Jackson is encoding instances of these classes as JSON using its default behavior, which produces the output you mentioned above. You may be able to get the behavior you want by writing Jackson mix-in annotations or custom serializers for the Geometry-related classes. | ||||||||||||||||||||||||||||||||||
| Comment by Julien Deruere [ 30/Nov/18 ] | ||||||||||||||||||||||||||||||||||
|
I was actually more talking about encoding the Geometry Object to RFC7946 compatible JSON. | ||||||||||||||||||||||||||||||||||
| Comment by Julien Deruere [ 30/Nov/18 ] | ||||||||||||||||||||||||||||||||||
|
Hi, I'm trying to develop on API that answer pure geojson object like Feature and Feature Collection, so I wrapped the com.mongodb.client.model.geojson.Geometry into a Feature POJO:
And then I'm doing this:
Should I develop a specific codec? | ||||||||||||||||||||||||||||||||||
| Comment by Jeffrey Yemin [ 30/Nov/18 ] | ||||||||||||||||||||||||||||||||||
|
Hi jderuere Thanks for the report. The com.mongodb.client.model.geojson.codecs.LineStringCodecSpecification#should round trip test indicates that it works as you expect. Would you be able to provide a snippet of Java code that reproduces the problem? Thanks, |