我正在尝试反序导出错误的json
。Int32
的值太大或太小。在查看堆栈跟踪时,不确定问题出在哪里。我试过并检查过每一栏。底部的packlist元素解释了每个部分中的列
有人能告诉我问题是什么吗
调用方法来反序列化的代码
var json = File.ReadAllText("Models\\Trigger2OutputMinified.json");
var o = JObject.Parse(json);
var tmp = JsonConvert.DeserializeObject<Trigger2Output>(o.ToString());
错误
在System.Convert.ToInt32(双值) 在System.Double.System.IConvertible.ToInt32(IFormatProvider提供程序) 在System.Convert.ToInt32(对象值,IFormatProvider提供程序) at Newtonsoft.Json.JsonReader.ReadAsInt32() at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract,Boolean hasConverter) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader,Type objectType,Boolean checkAdditionalContent) at Newtonsoft.Json.Serialization.JsonSerializerProxy.DeserializeInternal(JsonReader reader,Type objectType) 在Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader,Type objectType) at CoreAnalytics.Utilities.WebApi.MinifyingJsonConverter.ReadMinified(JArray value,Type propertyType,JsonSerializer serializer) 在CoreAnalytics.Utilities.WebApi.MinifyingJsonConverter。&lt;&gt; c__DisplayClass1_2.b__2(JToken j) 在System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() 在System.Linq.Buffer`1..ctor(IEnumerable`1 source) 在System.Linq.Enumerable.ToArray [TSource](IEnumerable`1 source) 在CoreAnalytics.Utilities.WebApi.MinifyingJsonConverter.ReadJson(JsonReader reader,Type objectType,Object existingValue,JsonSerializer serializer) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter,JsonReader reader,Type objectType,Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader,Type objectType,Boolean checkAdditionalContent) at Newtonsoft.Json.Serialization.JsonSerializerProxy.DeserializeInternal(JsonReader reader,Type objectType) 在Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader,Type objectType) 在CoreAnalytics.Utilities.WebApi.MinifyingJsonConverter.ReadJson(JsonReader reader,Type objectType,Object existingValue,JsonSerializer serializer) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter,JsonReader reader,Type objectType,Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader,Type objectType,Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader,Type objectType) at Newtonsoft.Json.JsonConvert.DeserializeObject(String value,Type type,JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject [T](String value,JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject [T](String value) 在Captives.API.Tests.Models.MatlabDeserializationTest.Trigger2_Output_Deserialize_JSON_Minified()在C:\ vstsprojects \ Risk.Analytics.Captives \ Serverside \ Captives.API.Tests \ Models \ MatlabDeserializationTest.cs:第57行
的Json
{
"NpvResults": {
"CommIns": [
[
1,
-112000,
-91317.124799724217,
44800,
36526.849919885448
],
[
2,
-116524.800000004,
-115186.42642741989,
46609.919999995334,
46074.570570973483
]
],
"CaptiveIns": [
[
1,
-112000,
-91317.124799724217,
44800,
36526.849919885448,
0,
0,
-2500000,
-2038328.6785651783,
0,
0,
0,
0
],
[
2,
-116524.800000004,
-115186.42642741989,
46609.919999995334,
46074.570570973483,
0,
0,
0,
0,
0,
0,
0,
0
]
],
"SelfIns": [
[
1,
-2995.0520596871575,
-2441.9602028223035,
1198.0208238748635,
976.78408112892225
],
[
2,
-2990.6443837985753,
-2956.2946195574036,
1196.2577535194309,
1182.5178478229618
]
],
"NetCost": [
[
0,
-1710520784.8208315,
-43166205.520741388,
-11902164177.646723,
-10191643392.825891,
1667354579.3000901,
-11858997972.125982
]
]
},
"EvaResults": {
"CaptiveView": [
[
1,
152085.99541639443,
2500000,
0.060834398166558029
],
[
2,
154609.22619904767,
2652085.9954163977,
0.058297216531136051
],
[
3,
155902.89180304483,
2806695.2216154449,
0.055546787765182772
]
],
"ParentView": [
[
1,
-128250,
0,
150000,
3920,
25670,
2500000,
0.010268000000001283
],
[
2,
-136052.01156486076,
0,
149515.2000000074,
4078.3680000003556,
17541.556435139009,
2652085.9954163977,
0.0066142515155674306
],
[
3,
-143983.46486887196,
0,
149265.50399998933,
4159.9353599996311,
9441.9744911277667,
2806695.2216154449,
0.0033640945685916796
],
[
4,
-151981.28321836866,
0,
149010.81407999995,
4243.1340672001061,
1272.6649288315675,
2962598.1134184771,
0.00042958368943973602
],
[
5,
-160047.50223759355,
0,
148751.03036161003,
4327.9967485442066,
-6968.4751274490773,
3119834.3516099928,
-0.0022335969153448256
]
],
"Overall": [
[
0,
3892084696.9739838,
70206068410.301788,
-3601571309.4484591,
0,
3732712742.2095885,
103647170.87865984,
234788603.63824561,
70206068410.301788,
0.055438009635116858,
0.0033442779086571605
]
]
},
"EndingSurplusResults": [
{
"perc25":
0,
"perc50":
0,
"mean":
0,
"perc75":
0,
"perc90":
0,
"perc95":
0
}
],
"FinancialStatements": {
"IncomeStatement": [
[
1,
110880,
1120,
112000,
2995.0520596871575,
7989.2402026057453,
0,
12000,
89015.707737707271,
128250,
-733413.04952323041,
217265.70773770701,
-516147.34178552142,
65179.712321312167,
-154844.20253565657,
152085.99541639443,
152085.99541639443,
-220023.91485696906,
0.098074038056186766,
0.10714285714284824,
0.20521689519904321
],
[
2,
115359.55199999372,
1165.2479999999437,
116524.800000004,
2990.6443837985753,
8429.0324747042687,
0,
12484.799999998904,
92620.323141497123,
128250,
-756576.39066074393,
220870.32314149709,
-535706.06751924916,
66261.096942449338,
-160711.82025577407,
154609.22619904767,
154609.22619904767,
-446996.83205519326,
0.098002115073382412,
0.10714285714284824,
0.20514497221623959
],
[
3,
117666.74304000707,
1188.5529600000007,
118855.29600000317,
2993.8905872056421,
8658.4925513012968,
0,
12734.495999999444,
94468.416861493111,
128250,
-767521.2727565337,
222718.41686149311,
-544802.85589503986,
66815.525058447893,
-163440.85676851199,
155902.89180304483,
155902.89180304483,
-677253.21388215246,
0.098038400733164791,
0.10714285714284824,
0.2051812578760219
],
[
4,
120020.07790080752,
1212.3240192001031,
121232.4019200031,
3001.7306822136966,
8868.2879013389193,
0,
12989.185920000074,
96373.197416447671,
128250,
-787974.95827768347,
224623.19741644754,
-563351.76086123544,
67386.95922493434,
-169005.52825837146,
157236.23819151349,
157236.23819151349,
-913645.70136545505,
0.09791127120772182,
0.10714285714284824,
0.20505412835057901
],
[
5,
122420.47945880973,
1236.5704995840629,
123657.04995839761,
2996.7390565652754,
9114.7872851512693,
0,
13248.969638399787,
98296.55397828354,
128250,
-813485.55497470719,
226546.55397828354,
-586939.00099642435,
67963.966193485045,
-176081.70029892743,
158582.58778479826,
158582.58778479826,
-1157691.3678578646,
0.097944487158564783,
0.10714285714284824,
0.20508734430142217
]
],
"CashFlow": [
[
1,
112000,
2995.0520596871575,
12000,
-154844.20253565657,
0,
251849.15047597012,
0,
128250,
2500000,
2880099.1504759672,
0,
0
],
[
2,
116524.800000004,
2990.6443837985753,
12484.799999998904,
-160711.82025577407,
0,
261761.1758719761,
0,
128250,
0,
3270110.3263479499,
2880099.1504759672,
0
],
[
3,
118855.29600000317,
2993.8905872056421,
12734.495999999444,
-163440.85676851199,
0,
266567.7661813054,
0,
128250,
0,
null,
null,
0
],
[
4,
121232.4019200031,
3001.7306822136966,
12989.185920000074,
-169005.52825837146,
0,
274247.01357615611,
0,
128250,
0,
null,
null,
0
],
[
5,
123657.04995839761,
2996.7390565652754,
13248.969638399787,
-176081.70029892743,
0,
283493.04156236141,
0,
128250,
0,
null,
null,
0
]
],
"BalanceSheet": [
[
1,
10000000,
-220023.91485696906,
0,
7989.2402026057453,
152085.99541639443,
10000000,
2500000,
0,
2500000,
2652085.9954163977,
0,
0,
12652085.99541642,
2660075.2356190062,
2880099.1504759672,
12880099.150475956
],
[
2,
10000000,
-446996.83205519326,
0,
16418.272677310033,
154609.22619904767,
10000000,
2500000,
2652085.9954163977,
0,
2806695.2216154449,
0,
0,
12806695.22161549,
2823113.4942927486,
3270110.3263479499,
13270110.326347981
],
[
3,
10000000,
-677253.21388215246,
0,
25076.765228611304,
155902.89180304483,
10000000,
2500000,
2806695.2216154449,
0,
2962598.1134184771,
0,
0,
12962598.113418501,
2987674.8786470997,
null,
null
],
[
4,
10000000,
-913645.70136545505,
0,
33945.053129950385,
157236.23819151349,
10000000,
2500000,
2962598.1134184771,
0,
3119834.3516099928,
0,
0,
13119834.351609999,
3153779.4047399526,
null,
null
],
[
5,
10000000,
-1157691.3678578646,
0,
43059.840415101455,
158582.58778479826,
10000000,
2500000,
3119834.3516099928,
0,
3278416.9393947939,
0,
0,
13278416.939394822,
3321476.7798099048,
null,
null
]
]
},
"PackList": [
{
"tblname": "CommIns",
"cols": "year;premPaid;discountedPremPaid;taxDeduction;discountedTaxDeduction",
"Item": "NpvResults"
},
{
"tblname": "CaptiveIns",
"cols": "year;premPaid;discountedPremPaid;taxDeduction;discountedTaxReduction;loanToParent;discountedLoanToParent;capContriDistr;discountedCapContriDistr;dividendDistr;discountedDividendDistr;terminalVal;discountedTerminalVal",
"Item": "NpvResults"
},
{
"tblname": "SelfIns",
"cols": "year;lossesPaid;discountedLossesPaid;taxDeduction;discountedTaxDeduction",
"Item": "NpvResults"
},
{
"tblname": "NetCost",
"cols": "layerId;commInsNetCost;selfInsNetCost;captiveInsNetCost;commVsCaptive;commVsSelf;selfVsCaptive",
"Item": "NpvResults"
},
{
"tblname": "CaptiveView",
"cols": "year;captiveNetIncome;surplusDeployed;impliedRoi",
"Item": "EvaResults"
},
{
"tblname": "ParentView",
"cols": "year;costOfCapDeployed;costOfRiskArb;incrCost;npvTaxBenefit;outcome;surplusDeployed;impliedRoi",
"Item": "EvaResults"
},
{
"tblname": "Overall",
"cols": "layerId;captiveNetIncome;captiveSurplusDeployed;parentCostOfCapDeployed;parentCostOfRiskArb;parentIncrCost;parentNpvTaxBenefit;parentOutcome;parentSurplusDeployed;captiveImpliedRoi;parentImpliedRoi",
"Item": "EvaResults"
},
{
"tblname": "IncomeStatement",
"cols": "year;directPremWritten;cededPremWritten;netPremWritten;lossesLaePaid;chgResIbnr;othrUwExp;gaExp;uwGain;netInvestmentIncome;irsDiscount;preTaxOpIncomeWithIrs;preTaxOpIncomeWithoutIrs;fedIncomeTaxWithIrs;fedIncomeTaxWithoutIrs;netOperatingIncome;netIncome;deferredTaxAssets;lossLaeRatio;expRatio;netCombinedRatio",
"Item": "FinancialStatements"
},
{
"tblname": "CashFlow",
"cols": "year;premCollected;lossLaePaid;gaExpPaid;fedIncomeTaxPaid;othrUwExpPaid;netCashByOpActivities;loanBack;invPurchasedSold;capPaidIn;cashInvEndOfYear;cashInvStartOfYear;dividendsPaid",
"Item": "FinancialStatements"
},
{
"tblname": "BalanceSheet",
"cols": "year;othrAssets;defFedIncTax;loanbackAsset;totLiabilities;retainedEarnings;nonControllingInt;capAdequacyReqd;capital;addnPaidInCap;shareholderEquity;additionallyNeeded;distribute;totShareholderEquity;totLiabilitiesTotShEquity;totCashInvestment;totAssets",
"Item": "FinancialStatements"
}
],
"StressTestAnalysis": [
{
"curlevel": 0.050000000000000003,
"decrease": 0.080000000000000002,
"increase": 0.089999999999999997
}
]
}
c#class
public class CommIns
{
[JsonMinify]
public int year { get; set; }
[JsonMinify]
public double premPaid { get; set; }
[JsonMinify]
public double discountedPremPaid { get; set; }
[JsonMinify]
public double taxDeduction { get; set; }
[JsonMinify]
public double discountedTaxDeduction { get; set; }
}
public class CaptiveIns
{
[JsonMinify]
public int year { get; set; }
[JsonMinify]
public double premPaid { get; set; }
[JsonMinify]
public double discountedPremPaid { get; set; }
[JsonMinify]
public double taxDeduction { get; set; }
[JsonMinify]
public double discountedTaxDeduction { get; set; }
[JsonMinify]
public double loanToParent { get; set; }
[JsonMinify]
public double discountedLoanToParent { get; set; }
[JsonMinify]
public double capContriDistr { get; set; }
[JsonMinify]
public double discountedCapContriDistr { get; set; }
[JsonMinify]
public int dividendDistr { get; set; }
[JsonMinify]
public int discountedDividendDistr { get; set; }
[JsonMinify]
public int terminalVal { get; set; }
[JsonMinify]
public int discountedTerminalVal { get; set; }
}
public class SelfIns
{
[JsonMinify]
public int year { get; set; }
[JsonMinify]
public double lossesPaid { get; set; }
[JsonMinify]
public double discountedLossesPaid { get; set; }
[JsonMinify]
public double taxDeduction { get; set; }
[JsonMinify]
public double discountedTaxDeduction { get; set; }
}
public class NetCost
{
[JsonMinify]
public int layerId { get; set; }
[JsonMinify]
public double commInsNetCost { get; set; }
[JsonMinify]
public double selfInsNetCost { get; set; }
[JsonMinify]
public double captiveInsNetCost { get; set; }
[JsonMinify]
public double commVsCaptive { get; set; }
[JsonMinify]
public double commVsSelf { get; set; }
[JsonMinify]
public double selfVsCaptive { get; set; }
}
[JsonConverter(typeof(MinifyingJsonConverter))]
public class NpvResults
{
public List<CommIns> CommIns { get; set; }
public List<CaptiveIns> CaptiveIns { get; set; }
public List<SelfIns> SelfIns { get; set; }
public List<NetCost> NetCost { get; set; }
}
public class CaptiveView
{
[JsonMinify]
public int year { get; set; }
[JsonMinify]
public double captiveNetIncome { get; set; }
[JsonMinify]
public double surplusDeployed { get; set; }
[JsonMinify]
public double impliedRoi { get; set; }
}
public class ParentView
{
[JsonMinify]
public int year { get; set; }
[JsonMinify]
public double costOfCapDeployed { get; set; }
[JsonMinify]
public int costOfRiskArb { get; set; }
[JsonMinify]
public int incrCost { get; set; }
[JsonMinify]
public double npvTaxBenefit { get; set; }
[JsonMinify]
public double outcome { get; set; }
[JsonMinify]
public double surplusDeployed { get; set; }
[JsonMinify]
public double impliedRoi { get; set; }
}
public class Overall
{
[JsonMinify]
public int layerId { get; set; }
[JsonMinify]
public double captiveNetIncome { get; set; }
[JsonMinify]
public double captiveSurplusDeployed { get; set; }
[JsonMinify]
public double parentCostOfCapDeployed { get; set; }
[JsonMinify]
public int parentCostOfRiskArb { get; set; }
[JsonMinify]
public int parentIncrCost { get; set; }
[JsonMinify]
public double parentNpvTaxBenefit { get; set; }
[JsonMinify]
public double parentOutcome { get; set; }
[JsonMinify]
public double parentSurplusDeployed { get; set; }
[JsonMinify]
public double captiveImpliedRoi { get; set; }
[JsonMinify]
public double parentImpliedRoi { get; set; }
}
[JsonConverter(typeof(MinifyingJsonConverter))]
public class EvaResults
{
public List<CaptiveView> CaptiveView { get; set; }
public List<ParentView> ParentView { get; set; }
public List<Overall> Overall { get; set; }
}
public class IncomeStatement
{
[JsonMinify]
public int year { get; set; }
[JsonMinify]
public double directPremWritten { get; set; }
[JsonMinify]
public int cededPremWritten { get; set; }
[JsonMinify]
public double netPremWritten { get; set; }
[JsonMinify]
public double lossesLaePaid { get; set; }
[JsonMinify]
public double chgResIbnr { get; set; }
[JsonMinify]
public int othrUwExp { get; set; }
[JsonMinify]
public int gaExp { get; set; }
[JsonMinify]
public double uwGain { get; set; }
[JsonMinify]
public double netInvestmentIncome { get; set; }
[JsonMinify]
public double irsDiscount { get; set; }
[JsonMinify]
public double preTaxOpIncomeWithIrs { get; set; }
[JsonMinify]
public double preTaxOpIncomeWithoutIrs { get; set; }
[JsonMinify]
public double fedIncomeTaxWithIrs { get; set; }
[JsonMinify]
public double fedIncomeTaxWithoutIrs { get; set; }
[JsonMinify]
public double netOperatingIncome { get; set; }
[JsonMinify]
public double netIncome { get; set; }
[JsonMinify]
public double deferredTaxAssets { get; set; }
[JsonMinify]
public double lossLaeRatio { get; set; }
[JsonMinify]
public int expRatio { get; set; }
[JsonMinify]
public double netCombinedRatio { get; set; }
}
public class CashFlow
{
[JsonMinify]
public int year { get; set; }
[JsonMinify]
public double premCollected { get; set; }
[JsonMinify]
public double lossLaePaid { get; set; }
[JsonMinify]
public int gaExpPaid { get; set; }
[JsonMinify]
public double fedIncomeTaxPaid { get; set; }
[JsonMinify]
public int othrUwExpPaid { get; set; }
[JsonMinify]
public double netCashByOpActivities { get; set; }
[JsonMinify]
public double loanBack { get; set; }
[JsonMinify]
public double invPurchasedSold { get; set; }
[JsonMinify]
public double capPaidIn { get; set; }
[JsonMinify]
public int dividendsPaid { get; set; }
[JsonMinify]
public double cashInvEndOfYear { get; set; }
[JsonMinify]
public double cashInvStartOfYear { get; set; }
}
public class BalanceSheet
{
[JsonMinify]
public int year { get; set; }
[JsonMinify]
public int othrAssets { get; set; }
[JsonMinify]
public double loanbackAsset { get; set; }
[JsonMinify]
public double totLiabilities { get; set; }
[JsonMinify]
public double retainedEarnings { get; set; }
[JsonMinify]
public int nonControllingInt { get; set; }
[JsonMinify]
public int capAdequacyReqd { get; set; }
[JsonMinify]
public double capital { get; set; }
[JsonMinify]
public double addnPaidInCap { get; set; }
[JsonMinify]
public double shareholderEquity { get; set; }
[JsonMinify]
public double additionallyNeeded { get; set; }
[JsonMinify]
public int distribute { get; set; }
[JsonMinify]
public double totShareholderEquity { get; set; }
[JsonMinify]
public double totLiabilitiesTotShEquity { get; set; }
[JsonMinify]
public double totCashInvestment { get; set; }
[JsonMinify]
public double totAssets { get; set; }
}
[JsonConverter(typeof(MinifyingJsonConverter))]
public class FinancialStatements
{
public List<IncomeStatement> IncomeStatement { get; set; }
public List<CashFlow> CashFlow { get; set; }
public List<BalanceSheet> BalanceSheet { get; set; }
}
public class StressTestAnalysis
{
public double curlevel { get; set; }
public double decrease { get; set; }
public double increase { get; set; }
}
public class EndingSurplus
{
public int perc25 { get; set; }
public int perc50 { get; set; }
public int mean { get; set; }
public int perc75 { get; set; }
public int perc90 { get; set; }
public int perc95 { get; set; }
}
[JsonConverter(typeof(MinifyingJsonConverter))]
public class Trigger2Output
{
public NpvResults NpvResults { get; set; }
public EvaResults EvaResults { get; set; }
public FinancialStatements FinancialStatements { get; set; }
public List<StressTestAnalysis> StressTestAnalysis { get; set; }
public List<EndingSurplus> EndingSurplus { get; set; }
}
答案 0 :(得分:0)
这已经解决了。我使用的技术是验证ball int字段和实际json文件中的相应值,并将数据类型更改为double