我正在尝试反序列化如下所示的 JSON:
{"METHOD":"GET_IVR_ACTION",
"DATA": {"DID":"972732248673",
"CALLER_ID":"972508822570",
"CALLER_NAME":null,
"IVR_UNIQUE_ID":"4c80c29146c61f3c24ed434e11cb340b",
"DTMF":"",
"MENU":"-1",
"PREVIOUS_MENU":"-1"}
}
进入这个类对象:
public class DATA
{
public string DID = string.Empty;
public string CALLER_ID = string.Empty;
public string CALLER_NAME = string.Empty;
public string IVR_UNIQUE_ID = string.Empty;
public string DTMF = string.Empty;
public string MENU = string.Empty;
public string PREVIOUS_MENU = string.Empty;
}
使用 JavaScriptSerializer:
JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
DATA data = jsonSerializer.Deserialize<DATA>(jsonString);
该对象仍然是令人失望的空...