我正在尝试在便携式类库中加载一些数据.数据采用JSON格式.我需要解析并处理这些信息.不幸的是,System.Json似乎不可用.与此同时,我试图包含Json.Net NuGet包,没有任何运气.
如何在可移植类库中使用JSON数据?
谢谢
我是MvvmCross和Android开发的新手.我需要在视图模型中调用POST数据到JSON Web服务.然后,我需要在我的UI中显示Web服务的结果.我的视图模型的要点如下所示:
public class MyViewModel : MvxViewModel
{
public override void Start()
{
base.Start();
}
public event EventHandler<EventArgs> Service_Finished;
public void CallService()
{
string url = GetServiceUrl();
WebRequest serviceRequest = HttpWebRequest.Create(url);
serviceRequest.Method = "POST";
serviceRequest.ContentType = "application/json";
serviceRequest.BeginGetRequestStream(new AsyncCallback(ServiceBeginGetRequestStreamCallback), serviceRequest);
}
private void ServiceBeginGetRequestStreamCallback(IAsyncResult ar)
{
string json = GetJson();
HttpWebRequest myWebRequest = (HttpWebRequest)(ar.AsyncState);
using (Stream postStream = myWebRequest.EndGetRequestStream(ar))
{
byte[] byteArray = Encoding.UTF8.GetBytes(json);
postStream.Write(byteArray, 0, byteArray.Length);
}
myWebRequest.BeginGetResponse(new AsyncCallback(Service_Completed), myWebRequest);
}
private void Service_Completed(IAsyncResult result)
{
if (Service_Finished != …Run Code Online (Sandbox Code Playgroud) 我正在开发Windows Phone 8应用程序.我的应用将包括应用内购买.我正在努力理解收据的概念.根据我的理解,在有人在我的应用程序内购买产品后,会生成收据.
<?xml version="1.0"?>
<Receipt Version="1.0" CertificateId="{Identifier1}" xmlns="http://schemas.microsoft.com/windows/2012/store/receipt">
<ProductReceipt PurchasePrice="${PurchaseAmount}" PurchaseDate="{DateTime}" Id="{Guid1}" AppId="{Guid2}" ProductId="{ProductName}" ProductType="Consumable" PublisherUserId="{Identifier2}" PublisherDeviceId="{Identifier3}" MicrosoftProductId="{Guid3}" />
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
<SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
<Reference URI="">
<Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /></Transforms>
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
<DigestValue>{Identifier4}</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>{HashedValue}</SignatureValue>
</Signature>
</Receipt>
Run Code Online (Sandbox Code Playgroud)
大!我不知道如何判断这张收据是否来自微软的服务器.有人可以向我解释如何验证吗?我看到了这个:http://code.msdn.microsoft.com/wpapps/In-app-purchase-receipt-c3e0bce4然而,这对我来说没有意义.我不明白示例中的证书."IapReceiptProduction.cer"是一套固定的东西吗?或者只是这个样本?
如果这是一个愚蠢的问题,我很抱歉.