JSON对象字符串转换为对象

{"startMonth":"1","endMonth":"5","day":"26","addMonth":"1"}
package admin.web.vo;

import lombok.Data;

import java.io.Serializable;

@Data
public class AccountMonth implements Serializable {

    private String startMonth;

    private String endMonth;

    private String day;


}
import com.alibaba.fastjson.JSON;
<dependency>
   <groupId>com.alibaba</groupId>
   <artifactId>fastjson</artifactId>
   <version>1.2.29</version>
</dependency
String configValue = "{"startMonth":"1","endMonth":"5","day":"26","addMonth":"1"}";

AccountMonth accountMonth = JSON.parseObject(configValue, AccountMonth.class);
原文地址:https://www.cnblogs.com/jcjssl/p/9443192.html