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

  • ChannelRichard

    ChannelRicha

    7 Kasım 2008
  • chickenby

    chickenby

    2 HAZİRAN 2008
  • FUNKER530 - Veteran Community & Combat Footage

    FUNKER530 -

    25 Ocak 2007