code: public static String toJson(Object object) {
          String jsonString = "";
          try {
              jsonString = objectMapper.writeValueAsString(object);
          } catch (Exception e) {
              log.warn("json error:" + e.getMessage());
          }
          return jsonString;
  
      }
docs: Java对象转Json字符串