我有以下的JSON:錯誤反序列化JSON無法反序列化JSON對象轉換類型 'System.String'
{"workspace": {
"name":"Dallas",
"dataStores":"http://.....:8080/geoserver/rest/workspaces/Dallas/datastores.json",
"coverageStores":"http://.....:8080/geoserver/rest/workspaces/Dallas/coveragestores.json",
"wmsStores":"http://....:8080/geoserver/rest/workspaces/Dallas/wmsstores.json"}}
而且我正嘗試反序列化INT這個類:
class objSON {
public string workspace { get; set; }
public string name { get; set; }
public string dataStores { get; set; }
public string coverageStores { get; set; }
public string wmsStores { get; set; }}
objWS_JSON deserContWS = JsonConvert.DeserializeObject<objWS_JSON>(data);
var coberturas = deserContWS.coverageStores;
var almacenesDatos = deserContWS.dataStores;
var almacenesWMS = deserContWS.wmsStores;
var nombre = deserContWS.name;
我得到以下錯誤:
無法將JSON對象反序列化爲類型'System.String'。
有什麼建議嗎?由於
感謝您的回答我解決了錯誤,但我的元素爲空 – JMG
您可以請你把你的序列化代碼在這裏 –
objWS_JSON deserContWS = JsonConvert.DeserializeObject(data); var coberturas = deserContWS.coverageStores; var almacenesDatos = deserContWS.dataStores; var almacenesWMS = deserContWS.wmsStores; var nombre = deserContWS.name; –
JMG