Comments (3)
Hi @rsvalerio!
BasicDBObject implements Map<String, Object>: http://api.mongodb.org/java/current/com/mongodb/BasicDBObject.html.
So this should already be possible.
What exception are you getting?
Regards,
Raรบl.
from camel-mongodb.
Hi @raulk .
Well, my problem is:
Route:
from("direct:get.beers")
.to("mongodb:local?database=poc&collection=beers&operation=findAll")
.split().body()
.convertBodyTo(String.class)
.unmarshal().xmljson()
.log(LoggingLevel.DEBUG, "### ${body}")
.end();
Throws:
nu.xom.IllegalNameException: NCNames cannot start with the character 24
Because:
{
"_id": {
"$oid": "538b8b63d69eb687a19caef7"
},
"type": "strong"
}
But even toMap() have an invalid json response:
public void toMap (
Exchange exchange,
@Body Map<String, Object> bodyImplementsMap ) {
Map<String, Object> bodyToMap = ((BasicDBObject)bodyImplementsMap).toMap();
exchange.getIn().setHeader("bodyImplementsMap", bodyImplementsMap);
exchange.getIn().setHeader("bodyToMap", bodyToMap);
}
bodyImplementsMap (valid json, invalid xml because $) :
{
"_id": {
"$oid": "538b8b63d69eb687a19caef7"
},
"type": "strong"
}
bodyToMap (invalid json, miss "", valid xml ) :
{
_id = 538b8b63d69eb687a19caef7,
type = strong
}
from camel-mongodb.
By now, converting response body from mongodb to Map as follows:
public void toMap ( Exchange exchange, @Body BasicDBObject body) {
ObjectId id = body.getObjectId("_id");
body.put("_id", id.toString());
exchange.getIn().setBody(body.clone());
}
from camel-mongodb.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from camel-mongodb.