我有以下Json
{"mapData":{"test":"success","publicKey":""},"statusCode":200,"message":null}
如何将以下json转换为Type脚本类
mapData 具有匿名值
{"test":"success","publicKey":""}
{"test":"success","publicKey":"","anotherKey":"anotherValue"}
那么我们如何才能将此json转换为键入脚本对象?
{"mapData":{"test":"success","publicKey":""},"statusCode":200,"message":null}
我的演示示例
export class GenericResponse {
mapData: any;
statusCode: number;
message: string;
}
以下是我用来将Object转换为Json的Java类
/**
* @author atwa
* Jul 2, 2018
*/
public class Response {
/**
* An Map that contains the actual objects
*/
private Map<String, Object> mapData =new HashMap<>();
/**
* A String containing error code. Set to 1 if there is an error
*/
private int statusCode = 0;
/**
* A String containing error message.
*/
private String message;
/**
* @return the mapData
*/
public Map<String, Object> getMapData() {
return mapData;
}
/**
* @param mapData
* the mapData to set
*/
public void setMapData(Map<String, Object> mapData) {
this.mapData = mapData;
}
}