Sabah,WebService'den nasıl JSON dönülür
Web servisimden bir ileti göndermem gerekiyor. Aşağıda kodumun bir örneği var ve bir string döndürüyorum.
[web method]
public string CheckFeedSubmission()
{
string responseText = "";
try
{
//Stuff goes here
responseText = "It Worked!"
}
catch (Exception ex) { responseText = "Opps wehave an error! Exception message:" + ex.Message; }
return responseText ;
}
Şu anda şu yanıtı almak ...
<string xmlns="http://tempuri.org/"/>
Ben ideal ben bu fikri aldıktan sonra eminim
{"success" : true, "message" : "***Message Here***"}
gibi bir şey dönmek istiyorum
i Gerekirse diğer öğeleri iade edebilecektir. Sadece bu üssü çalışmam gerek.
Tüm yardım çok önceden :)
GÜNCELLEME içinde sayesinde takdir: Sadece bu buldum ...
return "{Message:'hello world'}"
i
responseText = "{"success" : true, "message" : \"There has been an error. Message: " + ex.Message + "\"}"
olası yinelenen [web hizmeti json dönmelidir] (http://stackoverflow.com/questions/8205081/web -service-should-return-json) –