SORU
29 HAZİRAN 2009, PAZARTESİ


C JSON dize oluşturma#

Ben sadece XmlWriter geri, bir HTTP yanıtı göndermek için bazı XML oluşturmak için kullanılır. Nasıl bir JSON dize oluşturmak istiyorsunuz. Sadece JSON dize oluşturmak için bir stringbuilder kullanmak istiyorsunuz sanırım ve onlara yanıt olarak JSON formatında?

CEVAP
29 EYLÜL 2012, CUMARTESİ


Newtonsoft.Json kullanarak çok daha kolay hale getirir:

Product product = new Product();
product.Name = "Apple";
product.Expiry = new DateTime(2008, 12, 28);
product.Price = 3.99M;
product.Sizes = new string[] { "Small", "Medium", "Large" };

string json = JsonConvert.SerializeObject(product);

Belgeleri:Serializing and Deserializing JSON

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Joshua Benedict

    Joshua Bened

    26 EKİM 2013
  • LinusTechTips

    LinusTechTip

    25 Kasım 2008
  • Perihelion

    Perihelion

    23 NİSAN 2008