String value = "{\"key\":2,\"value\":3}"
LocalMap<String, String> map = ...
Object value = map.get(key);
JsonObject data = (JsonObject) value;
//--> java.lang.String cannot be cast to io.vertx.core.json.JsonObject
LocalMap<String, String> map = ...
Object value = map.get(key);
JsonObject data = new JsonObject((String) value);
//--> io.vertx.core.json.JsonObject cannot be cast to java.lang.String
I have a valid Json string as a local map value:
String value = "{\"key\":2,\"value\":3}"
How to get the JsonObject back from this string/map?
First try:
LocalMap<String, String> map = ...
Object value = map.get(key);
JsonObject data = (JsonObject) value;
//--> java.lang.String cannot be cast to io.vertx.core.json.JsonObject
Second try:
LocalMap<String, String> map = ...
Object value = map.get(key);
JsonObject data = new JsonObject((String) value);
//--> io.vertx.core.json.JsonObject cannot be cast to java.lang.String
It seems to be harder than everything else I did today :-)
Any idea how to solve this?
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/25ad0e54-e707-45db-be58-447b2c29dba4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Object value = someOtherJsonObject.getValue("value");
map.put(key, value); // automatically puts a JsonObject as value^^
Object value = someOtherJsonObject.getValue("value");
map.put(key, value.toString()); //uses encode() inside which is nice