On Tue, Apr 24, 2018 at 1:48 AM, xiao tan <txshon...@gmail.com> wrote:
> when i use jackson like this:
> String json="{"path":
> "/data/user/0/com.zhihu.android.mediastudio/files/mediastudio/2421cbc0-36c4-4b00-a8bd-f55e43bbb4bc/capture_1524547516358.mp4"}"
> mapper.read(json,File.class);
>
> i got an error:
>
> com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize
> instance of java.io.File out of START_OBJECT token

Jackson can only deserializer `java.io.File` instance from JSON String
value, so trying to bind from JSON Object
will not work. In this case a compatible Java object would look more like:

  public class FileContainer {
      public File path;
  }

so that property "path" would have value from which `java.io.File` can
be deserialized.

-+ Tatu +-

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jackson-user+unsubscr...@googlegroups.com.
To post to this group, send email to jackson-user@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to