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

  • Facebook Developers

    Facebook Dev

    24 ŞUBAT 2009
  • TheForgottenGamer1

    TheForgotten

    28 AĞUSTOS 2009
  • tinycammonitor

    tinycammonit

    14 Aralık 2010