0

私は

String s =
    {
      "code1" : {
        "price" : 100,
        "type" : null
      },
      "code2" : {
        "price" : 110,
        "type" : null
      }
    }

それから私は:

Object p = Mapper.readValue(s, Person.class);

したがって、 in で注釈が付けられたメソッドを実行@JsonCreatorPerson.classます。

@JsonCreator
static Person create(Map<String, Object> s) {
        s = Maps.filterValues(s, Predicates.instanceOf(Person.class));
        ...
    }

私の問題はs常に空です。確認したところ、値には apriceと aがありtypeます。しかし、私がそうするときps.get("code1").getClass()、それは私に与えますLinkedHashMap

何が起こっているのか理解できません...手がかりはありますか?

これは私のクラスですPerson(内部クラスです):

public static class Person{

        private int price;
        private String type;
        public Person(int price) {
            this.price = price;
        }
        public int getPrice() {
            return price;
        }
        public String getType() {
            return type;
        }
    }

ありがとう!

4

1 に答える 1