Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Problem: Data Transfer Issue between API and Angular #5765


User avatar
0
mmukkara created

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)
  • User Avatar
    0
    mmukkara created

    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))

  • User Avatar
    0
    ryancyq created
    Support Team

    i don't see any difference.

    in your screenshot , benefitEnrolmentRule is having ruleType: 2 and benefitOptionRule is having ruleType: 0

    which are reflected correctly in the json

  • User Avatar
    0
    mmukkara created

    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