我如何将get / post响应json转换为pojo类
例如我有一个像这样的json
{
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc"},
{"value": "Open", "onclick": "OpenDoc"},
{"value": "Close", "onclick": "CloseDoc"}
]
}
}
我有一个pojo类Example.ts
declare module Example {
export interface Menuitem {
value: string;
onclick: string;
}
export interface Popup {
menuitem: Menuitem[];
}
export interface RootObject {
popup: Popup;
}
}
我应该成功编写什么内容,以便上述响应自动转换为Example.ts
$.ajax({
url:'URL',
type: "GET",
success : function(responseText)
{
alert(JSON.stringify(responseText));
},
error: function(XMLHttpRequest, textStatus, errorThrown)
{
alert("Status: " + textStatus);
}
});