Grabacr07/KanColleViewer — pull request #50 by SquallATF (2014-01-10 04:37:31+00:00)
Title: right way to deserialize kcsapi_ship3 api_slot_data

Here is test code and value access method, 'ship3' is the full response content of '/kcsapi/api_get_member/ship3
'
public static void Test()
{
var settings = new DataContractJsonSerializerSettings { UseSimpleDictionaryFormat = true };
var serializer = new DataContractJsonSerializer(typeof(svdata), settings);
var ship2Text = System.IO.File.ReadAllText("ship3");
var ship2Json = ship2Text.Substring(7);
var rawResult = serializer.ReadObject(new MemoryStream(Encoding.UTF8.GetBytes(ship2Json))) as svdata;

for (int i = 0; i < rawResult.api_data.api_slot_data.Count; i++)
{
var value = rawResult.api_data.api_slot_data["api_slottype" + (i + 1)];
if (!value.Equals(-1))
{
var slotType = ((object[])value).Cast().ToList();
slotType.ForEach(t => Console.Write(t + ","));
Console.WriteLine();
}
}
var result = new SvData(rawResult);
}