Hi Guys,
I noticed the DTO object transfered to Angular has different map when it comes to child object.
Here is the issue.. API return dto BenefitOptionDto in quick watch
JSON on Angular.
{
"tenantId":2,
"id":4,
"classBenefitId":9,
"optionCode":"Option2",
"optionDescriptionEn":"Option2 Desc",
"isActive":true,
"benefitOptionPlans":[
{
"tenantId":2,
"id":4,
"benefitOptionId":4,
"ruleType":0,
"fromDate":"1900-01-01T05:00:00.000Z",
"ruleId":null
},
{
"benefitEnrolmentRule":{
"tenantId":2,
"id":2,
"trapLate":true,
"gracePeriod":"01M",
"dependentEnrolmentRules":[
{
"tenantId":2,
"benefitEnrolmentRuleId":2,
"dependent":1,
"waitingPeriod":"01D",
"startDateCalc":1,
"terminationAge":2,
"terminationDateCalc":1,
"terminationMonth":3,
"terminationDay":4,
"isEligible":false
}
],
"employmentRules":[
{
"tenantId":2,
"benefitEnrolmentRuleId":2,
"employmentType":1,
"minHours":3,
"frequency":1
}
],
"trappingRules":[
{
"tenantId":2,
"benefitEnrolmentRuleId":2,
"trappingCondition":2,
"nonEvidenceLimit":4,
"age":5,
"covBeforeDecision":1
}
]
},
"tenantId":2,
"id":5,
"benefitOptionId":4,
"ruleType":2,
"fromDate":"1900-01-01T05:00:00.000Z",
"ruleId":2
}
],
"isDefaultOption":false
}
If you compare both screen shot and JSON, "benefitEnrolmentRule" object should have been in the "ruleType":2 segment of benefitOptionPlans not "ruleType":0,.
This seems to be a big problem is parsing and serializing. Please help!
Thanks
3 Answer(s)
-
0
After further investigation, the problem is not related to parsing or serialization. The problem is with JSON.stringify
I wrote it to console log to get the above JSON and it is wrong. console.log("benefit " + JSON.stringify(this.benefitOption))
-
0
i don't see any difference.
in your screenshot ,
benefitEnrolmentRule
is havingruleType: 2
andbenefitOptionRule
is havingruleType: 0
which are reflected correctly in the json
-
0
In the screenshot... BenefitEnrolmentRule is Null for Ruletype 0 BenefitEnrolmentRule is Not Null for Ruletype 2
In JSON, BenefitEnrolmentRule is Not Null for Ruletype 0 BenefitEnrolmentRule doesn't exist for Ruletype 2