package org.springnewfiber.dataadapter.newfiber.entity; import com.alibaba.fastjson.JSONObject; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; import java.util.Date; @Data public class WaterQualityDto { @JsonProperty(value = "c") @ApiModelProperty(value = "水温") private BigDecimal c; @JsonProperty(value = "nh4n") @ApiModelProperty(value = "氨氮") private BigDecimal nh4n; @JsonProperty(value = "turb") @ApiModelProperty(value = "浊度") private BigDecimal turb; @JsonProperty(value = "algae") @ApiModelProperty(value = "蓝绿藻") private BigDecimal algae; @ApiModelProperty(value = "溶解氧") @JsonProperty(value = "dO") private BigDecimal dO; @JsonProperty(value = "cond") @ApiModelProperty(value = "电导率") private BigDecimal cond; @JsonProperty(value = "chla") @ApiModelProperty(value = "叶绿素a") private BigDecimal chla; @JsonProperty(value = "ph") @ApiModelProperty(value = "pH值") private BigDecimal ph; @JsonProperty(value = "tn") @ApiModelProperty(value = " 总氮") private BigDecimal tn; @JsonProperty(value = "tp") @ApiModelProperty(value = " 总磷") private BigDecimal tp; @JsonProperty(value = "codmn") @ApiModelProperty(value = " COD") private BigDecimal codmn; @ApiModelProperty(value = " st") private String st; @ApiModelProperty(value = " tt") private Date tt; public static void main(String[] args) { String str="{\"tt\":1667867700000,\"st\":\"0220100021\",\"c\":17.66419,\"nh4n\":0.50770,\"turb\":46.14257,\"algae\":17773.76367,\"dO\":8.23237,\"cond\":194.16431,\"chla\":0.00323,\"ph\":7.91721,\"tn\":1.01749,\"tp\":0.10019,\"codmn\":3.86996,\"ut\":1667867700000}"; WaterQualityDto dto=JSONObject.parseObject(str,WaterQualityDto.class); System.out.println(JSONObject.toJSONString(dto)); } }