LinkedHashMap转List对象报错

LinkedHashMap转List

了解LinkedHashMap

详细介绍(写的很好,感谢作者的分享)。

转换方法

例子


public class ResponseDto<T> {

	private boolean success;
	private int code;
	private String msg;
	private T data;

	public ResponseDto(){}

	public ResponseDto(ResponseCode responseCode) {
		code = responseCode.getCode();
		msg = responseCode.getMsg();
		success = responseCode.getCode() == ResponseCode.CODE_BASE_SUCCESS.getCode();
	}

	public ResponseDto(ResponseCode responseCode, T data){
		code = responseCode.getCode();
		msg = responseCode.getMsg();
		success = responseCode.getCode().equals(ResponseCode.CODE_BASE_SUCCESS.getCode());
		this.data = data;
	}

	public ResponseDto(ResponseCode responseCode, String msg) {
		code = responseCode.getCode();
		this.msg = msg;
		success = responseCode.getCode().equals(ResponseCode.CODE_BASE_SUCCESS.getCode());
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}
}

ResponseDto result = productChannel.queryType(param);
String listTxt = JSONArray.toJSONString(result.getData());
List<ResponseCodeDto> list = JSONArray.parseArray(listTxt, ResponseCodeDto.class);

在此记一下,欢迎指正!!

你可能感兴趣的:(JAVA)