The .pkpass
file is actually a ZIP archive. Inside the archive you'll find a pass.json
file which contain all meta data for the pass.
Use the Windows Phone compatible ZIP library Silverlight SharpZipLib to extract pass.json
from the .pkpass
.
string passDotJsonAsJson = null;
using(Stream pkpassAsStream = await client.GetPkpass())
{
responseStream.Position = 0;
using(ZipFile pkpass = new ZipFile(pkpassAsStream))
{
var passDotJson = pkpass.GetEntry("pass.json");
using (var passDotJsonAsStream = pkpass.GetInputStream(passDotJson))
{
var reader = new StreamReader(passDotJsonAsStream);
passDotJsonAsJson = await reader.ReadToEndAsync();
}
}
}
And there you have it. passDotJsonAsJson
does now contain the pass as a json string. You can now use Json.NET to make it a .NET object.