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

  • CaptainDisillusion

    CaptainDisil

    18 EYLÜL 2007
  • JayzTwoCents

    JayzTwoCents

    26 AĞUSTOS 2012
  • NPR

    NPR

    22 NİSAN 2006