How to read json file into java with jackson library?

I want to read this simple JSONfile with java jackson library(I'm new to JSON).

Coud you please tell to me what i do wrong?I created class or JSON object wrongly or this metod of convertion JSON object to Java is wrong, thanks

Edit now i get set of exception like this

enter image description here

This is what the JSONfile stores

      "id": 15,
      "name": "Steve",
      "Datax": {
        "veek": "vect",
        "seev": "vecs"

And i have three classes

Here is a Cevan:

public class Cevan {
    private int id;
    private String name;
    private Datax data;

    public Datax getData() {
        return data;

    public void setData(Datax data) { = data;

    public void setName(String name) { = name;

    public String getName() {
        return name;

    public void setId(int id) { = id;

    public int getId() {
        return id;

and Datax:

public class Datax {
    private String veek;
    private String seev;

    public String getSeev() {
        return seev;

    public String getVeek() {
        return veek;

    public void setSeev(String seev) {
        this.seev = seev;

    public void setVeek(String veek) {
        this.veek = veek;

and Class Main:

 public class Main {
    public static void main(String[] args) throws IOException {
        ObjectMapper mapper=new ObjectMapper();
        InputStream is=Cevan.class.getClassLoader().getResourceAsStream("src/main/resources/json2.json");
        Cevan testObj = mapper.readValue(is, Cevan.class);


When I run project i get this

It's like my project looks

Read more here:

Content Attribution

This content was originally published by Thebsemgoxcsa at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: