-1
如果我有一個類Contact
:讀寫對象JSON
public class Contact
{
public Contact()
{
}
public int ID { get; set;}
public string firstName { get; set;}
public string lastName { get; set;}
}
在我的代碼
我實例5個不同Contact
對象及其特定的屬性,然後將它們放到一個List<Contact>
。
我的問題:
- 我怎麼能轉換
List<Contact>
以JSON? - 如何將JSON讀回
List<Contact>
? - 如何從JSON中讀取ID 123的聯繫人並實例化一個
Contact
對象,以便擁有所有屬性?
非常感謝您的幫助! 謝謝!
P.S.該JSON會是這個樣子?
{
contacts:{
contact:[
{
id:123,
firstname:'jhon',
lastname:'smith'
},
{
id:1234,
firstname:'robert',
lastname:'smith'
}
]
}
}
[你有什麼嘗試](http://whathaveyoutried.com)? – Oded 2012-07-27 19:14:49
這個在線工具:http://www.thomasfrank.se/xml_to_json.html :)。那麼我對JSON有點新鮮。我知道如何製作一個XML,但沒有JSON。我正在考慮製作XML,而不是將其轉換爲JSON,但我認爲並希望有一種方法可以直接向JSON執行,從而避免不必要的XML工作。 – user1493460 2012-07-27 19:16:32
並在你的代碼? – Oded 2012-07-27 19:18:15