using Deloitte.ReportWizard.Domain.WorkingPaper;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization.Json;
using System.Text;
using Xunit;
namespace XUnitTestRCS.JavaAPITest
{
public class WordToJson
{
/// <summary>
/// json文件反序列化
/// </summary>
[Fact]
public void WordToJsonDeserialization()
{
string jsonfile = @"C:\Users\bigeg\Desktop\output\144董事会报告_2019 Annual Results Ann(c) 20200325_调格式_0125(1).json";//JSON文件路径
DataContractJsonSerializer js = new DataContractJsonSerializer(typeof(FinancialStatements));
try
{
StreamReader sr = new StreamReader(jsonfile);
string dir = sr.ReadToEnd();
System.IO.StreamReader file = System.IO.File.OpenText(jsonfile);
JsonTextReader reader = new JsonTextReader(file);
JObject o = (JObject)JToken.ReadFrom(reader);
if (o != null)
{
string json = o.ToString();//.Replace("ReportWizard", "Deloitte.ReportWizard");
var notes = JsonConvert.DeserializeObject<FinancialStatements>(json, new JsonSerializerSettings()
{
TypeNameHandling = TypeNameHandling.All
});
}
//var json = ReadJson(jsonfile);
// var jsonResult = JsonConvert.DeserializeObject<FinancialStatements>(json, new JsonSerializerSettings());
}
catch (Exception ex)
{
throw;
}
}
}
}
json转Model
最新推荐文章于 2024-08-08 20:23:02 发布