1、创建对象

import java.io.Serializable;
import com.alibaba.fastjson.annotation.JSONField;
public class PushMsgContent implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	
	private String amt1;//	本金  amt1
	private String amt2;//	放款金额    amt2
	private String amt3;//	应还本利合计为  amt3
	
	
	@JSONField(name = "amt1")//对应json中的key值
	public String getAmt1() {
		return amt1;
	}
	public void setAmt1(String amt1) {
		this.amt1 = amt1;
	}
	@JSONField(name = "amt2")
	public String getAmt2() {
		return amt2;
	}
	public void setAmt2(String amt2) {
		this.amt2 = amt2;
	}
	@JSONField(name = "amt3")
	public String getAmt3() {
		return amt3;
	}
	public void setAmt3(String amt3) {
		this.amt3 = amt3;
	}
}

2、使用alibabajson把json字符串转对象import com.alibaba.fastjson.JSON;
String msgContent = “{json字符串}”;
PushMsgContent pushMsgContent = JSON.parseObject(msgContent,PushMsgContent.class);

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐