Can we make object as key in map when using JSON?

后端 未结 4 1440
悲哀的现实
悲哀的现实 2020-11-30 10:56

As the code below:

public class Main {

    public class innerPerson{
        private String name;
        public String getName(){
            return name;
         


        
4条回答
  •  猫巷女王i
    2020-11-30 11:49

    In addition to existing correct answers, you can also add custom key serializers and key deserializers using Module interface (usually with SimpleModule). This allows you to externally define serialization and deserialization of keys. Either way, keys in JSON must be Strings, like others have pointed out.

提交回复
热议问题