class DymicObject {
     private Object o;

    public DymicObject(Object o) {
         this.o = o;
     }

    public DymicObject get(String s) {
         return new DymicObject(innerget(this.o, s));
     }


     public DymicObject get(int s) {
         return new DymicObject(innerget(this.o, s));
     }


     public Object Value() {
         return this.o;
     }

    private Object innerget(Object o, Object key) {
         if (o instanceof Map) {
             return ((Map) o).get(key);
         } else if (o instanceof List) {
             return ((List) o).get((Integer) key);
         }

        throw new RuntimeException("不支持");
     }





// example
  String body = message.getBody();

                ObjectMapper objectMapper = new ObjectMapper();

                Object o = objectMapper.readValue(body, Object.class);

                Object value = new DymicObject(o).get("Records").get(0).get("s3").get("bucket").get("name").Value();

相关文章:

  • 2021-09-29
  • 2021-07-19
  • 2022-12-23
  • 2021-12-18
  • 2021-10-20
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
  • 2021-07-18
  • 2022-01-18
  • 2022-12-23
相关资源
相似解决方案