private void Deserialize(Stream stream) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(Json.ApiResponse)); try { Response = serializer.ReadObject(stream) as Json.ApiResponse; Response.Status = new Json.StatusCode(Response.MetaData.Title, Response.MetaData.Status, Response.MetaData.Message); if (Response.Documents != null) { for (int i = 0; i < Response.Documents.Length; i++) { Response.Documents[i].Date = Response.MetaData.Parameter.Date; DateTime date = DateTime.Parse(Response.MetaData.Parameter.Date); Response.Documents[i].Id = int.Parse(date.ToString("yyMMdd")) * 10000 + Response.Documents[i].SeqNumber; Response.Documents[i].Status = GetStatus(Response.Documents[i]); if (Response.Documents[i].SecCode != null && Response.Documents[i].SecCode.Length > 3 && int.TryParse(Response.Documents[i].SecCode.Substring(0, 4), out int code)) { Response.Documents[i].Code = code; } else { Response.Documents[i].Code = null; } } } } catch (Exception) { //JSON以外のテキストファイルを読み込んだ場合のエラー回避 } }
public void Update(Json.ApiResponse json, Nullable <HttpStatusCode> status, MediaTypeHeaderValue contentType) { base.Update(json.Status, status, contentType); Json = json; }