java - com.fasterxml.jackson.databind.node.ObjectNode cannot be converted to org.codehaus.jackson.node.ObjectNode -
i'm using play2.2.1 , facing error:
com.fasterxml.jackson.databind.node.objectnode cannot converted org.codehaus.jackson.node.objectnode
the code this:
package controllers; import play.*; import play.data.*; import play.mvc.*; import play.db.ebean.*; import views.html.*; import java.util.*; import models.*; import com.avaje.ebean.expressionlist; import play.data.validation.constraints.required; import scala.*; import play.libs.json; import org.codehaus.jackson.node.objectnode; public class application extends controller { //create json data public static result ajax() { string input = request().body().asformurlencoded().get("input")[0]; objectnode result = json.newobject(); if(input == null) { result.put("status", "bad"); result.put("message", "can't sending data..."); return badrequest(result); } else { result.put("status", "ok"); result.put("message", input); return ok(result); } }
and error occurs @ objectnode result = json.newobject();
. however, confirmed return value of static method newobject()
org.codehaus.jackson.node.objectnode
[][1]https://playframework.com/documentation/2.0/api/java/play/libs/json.html
the version of api reference 2.0, not 2.2, different exists here? profoundly, when import com.fasterxml.jackson.databind.node.objectnode
, delete import org.codehaus.jackson.node.objectnode;
, application works well. can explain behavior? why error message contradict api reference?
i assume there 2 versions of jackson
library mixed in 1 project. old versions use org.codehaus.jackson
namespace, while newer versions use com.fasterxml.jackson
, because moved codehaus. had same problem, when used newer version of jackson , refactoring did not work properly. classes not compatible, have use com.fasterxml.jackson
consistently.
Comments
Post a Comment