question

suryapsingh2019 avatar image
0 Votes"
suryapsingh2019 asked suryapsingh2019 commented

Insert a node as child ,before or after a node in nested dynamic JSON Node using C#

I have below Dynamic nested JSON in which a node can contain multiple child nodes. Each node can have any number of sibilings. Also a Node can have child up to any number of level of depth.
Now i have task of adding a new node either as sibiling before, after or as child to a particular node. based on matching text. for example I pass a SearchText= "How are you doing?". so logic should work like this.
1. first it will find node Say 'MatchedNode' which has text matching with SearchText.
2. If Selected Option is 'Before' It will create a new blank node and add it to before 'MatchedNode'
3. If Selected Option is 'After' It will create a new blank node and add it to After 'MatchedNode'
4. If Selected Option is 'Child' It will create a new blank node and add it as child node to 'MatchedNode'

I am using recursion to iterate through nested JSON.

  private void NewSaveDraft()
         {
            InMemoryFileData = File.ReadAllText(filelocation);
             dynamic data = JObject.Parse(InMemoryFileData);
    
             for (int sectionIndex = 0; sectionIndex < data.Sections.Count; sectionIndex++)
             {
                 if (data.Sections[sectionIndex].Name == JSONTreeView.SelectedNode.Tag)
                 {
                     SaveDraftData(data.Sections[sectionIndex]);
                     return;
                 }
                 else
                 {
                     foreach (var node in data.Sections[sectionIndex].Nodes)
                         findSelectedNode(node);
                 }
             }
         }
    
         private void findSelectedNode(dynamic node)
         {
             if (node.Tag == JSONTreeView.SelectedNode.Tag)
             {
                 SaveDraftData(node);
                 return;
             }
             else
                 foreach (var n in node.Nodes)
                     findSelectedNode(n);
    
         }
    
         private void SaveDraftData(dynamic node)
         {
             ChangeNodeDataForSelectedNode(node);
                
         }
          
         private void ChangeNodeDataForSelectedNode(dynamic obj)
         {
       if (SelectedContextMenuOption.Equals("C"))
             obj.Nodes.Add(new Node());
               
    
         }

here definition of a node is below

 {
   "Actions": [
     {
       "Rule": "",
       "ActionCmds": [
         {
           "ActionCmd": "",
           "ParentNode": ""
         }
       ]
     }
   ],
   "Name": "ChildDepthLevel4",
   "Text": "ChildDepthLevel4",
   "HelpText": "",
   "InputCaptureRules": {
     "Min": 0,
     "Max": 0
   },
   "Tag": "ChildDepthLevel4",
   "IsRoot": true,
   "IsOptional": false,
   "IsLabel": false,
   "Note": {
     "Format": "",
     "Items": [
       {
         "Style": "",
         "Text": ""
       }
     ]
   },
   "HasPlaceHolderInText": false,
   "Benefits": [
     ""
   ],
   "Style": "",
   "IsConfirmationRequired": false,
   "Nodes": []
 }





a New Blank Node is like below

 {
   "Actions": [
     {
       "Rule": "",
       "ActionCmds": [
         {
           "ActionCmd": "",
           "ParentNode": ""
         }
       ]
     }
   ],
   "Name": "",
   "Text": "",
   "HelpText": "",
   "InputCaptureRules": {
     "Min": 0,
     "Max": 0
   },
   "Tag": "",
   "IsRoot": true,
   "IsOptional": false,
   "IsLabel": false,
   "Note": {
     "Format": "",
     "Items": [
       {
         "Style": "",
         "Text": ""
       }
     ]
   },
   "HasPlaceHolderInText": false,
   "Benefits": [
     ""
   ],
   "Style": "",
   "IsConfirmationRequired": false,
   "Nodes": []
 }

I am using recursion to iterate through nested JSON.

Below is sample JSON





 {
   "Name": "General H&L",
   "Version": "1.2",
   "NameSpace": "",
   "Sections": [
     {
       "Name": "Height-weight",
       "Nodes": [
         {
           "Actions": [
             {
               "Rule": "(Whatisyourexactheightincmsfeetandinches4604 = \"Cms\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "OpenNode 4605",
                   "ParentNode": null
                 }
               ]
             },
             {
               "Rule": "(Whatisyourexactheightincmsfeetandinches4604 = \"Feet & Inches\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "OpenNode 4606",
                   "ParentNode": null
                 },
                 {
                   "ActionCmd": "OpenNode 4607",
                   "ParentNode": null
                 }
               ]
             }
           ],
           "Name": "4604",
           "Text": "What is your exact height in cms, feet and inches?",
           "HelpText": null,
           "InputCaptureRules": {},
           "Tag": "Whatisyourexactheightincmsfeetandinches4604",
           "IsRoot": true,
           "IsOptional": false,
           "IsLabel": false,
           "Note": null,
           "HasPlaceHolderInText": false,
           "Benefits": [
             "DTH",
             "TPD",
             "TRA"
           ],
           "Style": null,
           "IsConfirmationRequired": false,
           "Nodes": [
             {
               "Actions": [
                 {
                   "Rule": "(HeightCms4605 >= 90) AND (HeightCms4605 <= 220)",
                   "ActionCmds": [
                     {
                       "ActionCmd": "Calculator, BMI, BMI",
                       "ParentNode": null
                     }
                   ]
                 }
               ],
               "Name": "4605",
               "Text": "Height (Cms)",
               "HelpText": null,
               "InputCaptureRules": {
                 "Min": 90,
                 "Max": 220
               },
               "Tag": "HeightCms4605",
               "IsRoot": false,
               "IsOptional": false,
               "IsLabel": false,
               "Note": null,
               "HasPlaceHolderInText": false,
               "Benefits": [
                 "DTH",
                 "TPD",
                 "TRA"
               ],
               "Style": null,
               "IsConfirmationRequired": false,
               "Nodes": []
             },
             {
               "Actions": [
                 {
                   "Rule": "(HeightFeet4606 >= 3) AND (HeightFeet4606 <= 7)",
                   "ActionCmds": [
                     {
                       "ActionCmd": "Calculator, BMI, BMI",
                       "ParentNode": null
                     }
                   ]
                 }
               ],
               "Name": "4606",
               "Text": "Height (Feet)",
               "HelpText": null,
               "InputCaptureRules": {
                 "Min": 3,
                 "Max": 7
               },
               "Tag": "HeightFeet4606",
               "IsRoot": false,
               "IsOptional": false,
               "IsLabel": false,
               "Note": null,
               "HasPlaceHolderInText": false,
               "Benefits": [
                 "DTH",
                 "TPD",
                 "TRA"
               ],
               "Style": null,
               "IsConfirmationRequired": false,
               "Nodes": []
             },
             {
               "Actions": [
                 {
                   "Rule": "(HeightInches4607 >= 0) AND (HeightInches4607 <= 12)",
                   "ActionCmds": [
                     {
                       "ActionCmd": "Calculator, BMI, BMI",
                       "ParentNode": null
                     }
                   ]
                 }
               ],
               "Name": "4607",
               "Text": "Height (Inches)",
               "HelpText": null,
               "InputCaptureRules": {
                 "Min": 0,
                 "Max": 12
               },
               "Tag": "HeightInches4607",
               "IsRoot": false,
               "IsOptional": false,
               "IsLabel": false,
               "Note": null,
               "HasPlaceHolderInText": false,
               "Benefits": [
                 "DTH",
                 "TPD",
                 "TRA"
               ],
               "Style": null,
               "IsConfirmationRequired": false,
               "Nodes": []
             }
           ]
         },
         {
           "Actions": [
             {
               "Rule": "(Whatisyourexactweightinkgslbsorstones4608 = \"Kgs\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "OpenNode 4609",
                   "ParentNode": null
                 }
               ]
             },
             {
               "Rule": "(Whatisyourexactweightinkgslbsorstones4608 = \"Lbs\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "OpenNode 4610",
                   "ParentNode": null
                 }
               ]
             },
             {
               "Rule": "(Whatisyourexactweightinkgslbsorstones4608 = \"Stones\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "OpenNode 4611",
                   "ParentNode": null
                 },
                 {
                   "ActionCmd": "OpenNode 4612",
                   "ParentNode": null
                 }
               ]
             }
           ],
           "Name": "4608",
           "Text": "What is your exact weight in kgs, lbs or stones?",
           "HelpText": null,
           "InputCaptureRules": {},
           "Tag": "Whatisyourexactweightinkgslbsorstones4608",
           "IsRoot": true,
           "IsOptional": false,
           "IsLabel": false,
           "Note": null,
           "HasPlaceHolderInText": false,
           "Benefits": [
             "DTH",
             "TPD",
             "TRA"
           ],
           "Style": null,
           "IsConfirmationRequired": false,
           "Nodes": [
             {
               "Actions": [
                 {
                   "Rule": "(WeightKgs4609 > 0)",
                   "ActionCmds": [
                     {
                       "ActionCmd": "Calculator, BMI, BMI",
                       "ParentNode": null
                     }
                   ]
                 }
               ],
               "Name": "4609",
               "Text": "Weight (Kgs)",
               "HelpText": null,
               "InputCaptureRules": {
                 "Min": 1
               },
               "Tag": "WeightKgs4609",
               "IsRoot": false,
               "IsOptional": false,
               "IsLabel": false,
               "Note": null,
               "HasPlaceHolderInText": false,
               "Benefits": [
                 "DTH",
                 "TPD",
                 "TRA"
               ],
               "Style": null,
               "IsConfirmationRequired": false,
               "Nodes": []
             },
             {
               "Actions": [
                 {
                   "Rule": "(WeightLbs4610 > 0)",
                   "ActionCmds": [
                     {
                       "ActionCmd": "Calculator, BMI, BMI",
                       "ParentNode": null
                     }
                   ]
                 }
               ],
               "Name": "4610",
               "Text": "Weight (Lbs)",
               "HelpText": null,
               "InputCaptureRules": {
                 "Min": 1
               },
               "Tag": "WeightLbs4610",
               "IsRoot": false,
               "IsOptional": false,
               "IsLabel": false,
               "Note": null,
               "HasPlaceHolderInText": false,
               "Benefits": [
                 "DTH",
                 "TPD",
                 "TRA"
               ],
               "Style": null,
               "IsConfirmationRequired": false,
               "Nodes": []
             },
             {
               "Actions": [
                 {
                   "Rule": "(WeightStones4611 > 0)",
                   "ActionCmds": [
                     {
                       "ActionCmd": "Calculator, BMI, BMI",
                       "ParentNode": null
                     }
                   ]
                 }
               ],
               "Name": "4611",
               "Text": "Weight (Stones)",
               "HelpText": null,
               "InputCaptureRules": {
                 "Min": 1
               },
               "Tag": "WeightStones4611",
               "IsRoot": false,
               "IsOptional": false,
               "IsLabel": false,
               "Note": null,
               "HasPlaceHolderInText": false,
               "Benefits": [
                 "DTH",
                 "TPD",
                 "TRA"
               ],
               "Style": null,
               "IsConfirmationRequired": false,
               "Nodes": []
             },
             {
               "Actions": [
                 {
                   "Rule": "(WeightLbs4612 >= 0) AND (WeightLbs4612 < 14)",
                   "ActionCmds": [
                     {
                       "ActionCmd": "Calculator, BMI, BMI",
                       "ParentNode": null
                     }
                   ]
                 }
               ],
               "Name": "4612",
               "Text": "Weight (Lbs)",
               "HelpText": null,
               "InputCaptureRules": {
                 "Min": 0,
                 "Max": 13
               },
               "Tag": "WeightLbs4612",
               "IsRoot": false,
               "IsOptional": false,
               "IsLabel": false,
               "Note": null,
               "HasPlaceHolderInText": false,
               "Benefits": [
                 "DTH",
                 "TPD",
                 "TRA"
               ],
               "Style": null,
               "IsConfirmationRequired": false,
               "Nodes": []
             }
           ]
         },
         {
           "Actions": [
             {
               "Rule": "(Areyounoworhaveyoueverreceivedtreatmentforanorexiaorbulimia4614 = \"No\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "OpenNode 4615",
                   "ParentNode": null
                 }
               ]
             },
             {
               "Rule": "(Areyounoworhaveyoueverreceivedtreatmentforanorexiaorbulimia4614 = \"Yes\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "Outcome, Decline, DTH, 'due to BMI >= 16.0 and < 17 and having received treatment for anorexia or bulimia', 1069",
                   "ParentNode": null
                 },
                 {
                   "ActionCmd": "Outcome, Decline, TRA, 'due to BMI >= 16.0 and < 17 and having received treatment for anorexia or bulimia', 1069",
                   "ParentNode": null
                 }
               ]
             }
           ],
           "Name": "4614",
           "Text": "Are you now or have you ever received treatment for anorexia or bulimia?",
           "HelpText": null,
           "InputCaptureRules": {},
           "Tag": "Areyounoworhaveyoueverreceivedtreatmentforanorexiaorbulimia4614",
           "IsRoot": false,
           "IsOptional": false,
           "IsLabel": false,
           "Note": null,
           "HasPlaceHolderInText": false,
           "Benefits": [
             "DTH",
             "TRA"
           ],
           "Style": null,
           "IsConfirmationRequired": false,
           "Nodes": []
         },
         {
           "Actions": [
             {
               "Rule": "(Haveyouexperiencedanyunexplainedweightlossofmorethanthreekgorsevenlbsinthelasttwelvemonths4615 = \"Yes\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "Outcome, Decline, DTH, 'due to BMI >= 16.0 and < 17 and having unexplained weight loss', 1068",
                   "ParentNode": null
                 },
                 {
                   "ActionCmd": "Outcome, Decline, TRA, 'due to BMI >= 16.0 and < 17 and having unexplained weight loss', 1068",
                   "ParentNode": null
                 }
               ]
             },
             {
               "Rule": "(Haveyouexperiencedanyunexplainedweightlossofmorethanthreekgorsevenlbsinthelasttwelvemonths4615 = \"No\") AND (Smoker = \"Non Smoker\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "LoadingPercent, DTH, 'LOADING: 50% due to BMI <17', 50.0000%, '', 565",
                   "ParentNode": null
                 },
                 {
                   "ActionCmd": "LoadingPercent, TRA, 'LOADING: 50% due to BMI <17', 50.0000%, '', 565",
                   "ParentNode": null
                 }
               ]
             },
             {
               "Rule": "(Haveyouexperiencedanyunexplainedweightlossofmorethanthreekgorsevenlbsinthelasttwelvemonths4615 = \"No\") AND (Smoker = \"Smoker\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "LoadingPercent, DTH, 'LOADING: 75% due to BMI <17 and being a smoker', 75.0000%, '', 566",
                   "ParentNode": null
                 },
                 {
                   "ActionCmd": "LoadingPercent, TRA, 'LOADING: 75% due to BMI <17 and being a smoker', 75.0000%, '', 566",
                   "ParentNode": null
                 }
               ]
             }
           ],
           "Name": "4615",
           "Text": "Have you experienced any unexplained weight loss of more than 3kg or 7 lbs in the last 12 months?",
           "HelpText": null,
           "InputCaptureRules": {},
           "Tag": "Haveyouexperiencedanyunexplainedweightlossofmorethanthreekgorsevenlbsinthelasttwelvemonths4615",
           "IsRoot": false,
           "IsOptional": false,
           "IsLabel": false,
           "Note": null,
           "HasPlaceHolderInText": false,
           "Benefits": [
             "DTH",
             "TRA"
           ],
           "Style": null,
           "IsConfirmationRequired": false,
           "Nodes": []
         },
         {
           "Actions": [
             {
               "Rule": "(Areyounoworhaveyoueverreceivedtreatmentforanorexiaorbulimia4617 = \"No\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "OpenNode 4618",
                   "ParentNode": null
                 }
               ]
             },
             {
               "Rule": "(Areyounoworhaveyoueverreceivedtreatmentforanorexiaorbulimia4617 = \"Yes\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "Outcome, Decline, DTH, 'due to BMI >= 17 & BMI < 18 and have received  treatment for anorexia', 1070",
                   "ParentNode": null
                 },
                 {
                   "ActionCmd": "Outcome, Decline, TRA, 'due to BMI >= 17 & BMI < 18 and have received  treatment for anorexia', 1070",
                   "ParentNode": null
                 }
               ]
             }
           ],
           "Name": "4617",
           "Text": "Are you now or have you ever received treatment for anorexia or bulimia?",
           "HelpText": null,
           "InputCaptureRules": {},
           "Tag": "Areyounoworhaveyoueverreceivedtreatmentforanorexiaorbulimia4617",
           "IsRoot": false,
           "IsOptional": false,
           "IsLabel": false,
           "Note": null,
           "HasPlaceHolderInText": false,
           "Benefits": [
             "DTH",
             "TPD",
             "TRA"
           ],
           "Style": null,
           "IsConfirmationRequired": false,
           "Nodes": [
             {
               "Actions": [
                 {
                   "Rule": "(Haveyouexperiencedanyunexplainedweightlossofmorethanthreekgorsevenlbsinthelasttwelvemonths4618 = \"Yes\")",
                   "ActionCmds": [
                     {
                       "ActionCmd": "OpenNode 4619",
                       "ParentNode": null
                     },
                     {
                       "ActionCmd": "OpenNode 4620",
                       "ParentNode": null
                     },
                     {
                       "ActionCmd": "OpenNode 4621",
                       "ParentNode": null
                     },
                     {
                       "ActionCmd": "OpenNode 4622",
                       "ParentNode": null
                     },
                     {
                       "ActionCmd": "Outcome, Refer, DTH, 'Build', 400",
                       "ParentNode": null
                     },
                     {
                       "ActionCmd": "Outcome, Refer, TPD, 'Build', 400",
                       "ParentNode": null
                     },
                     {
                       "ActionCmd": "Outcome, Refer, TRA, 'Build', 400",
                       "ParentNode": null
                     }
                   ]
                 },
                 {
                   "Rule": "(Haveyouexperiencedanyunexplainedweightlossofmorethanthreekgorsevenlbsinthelasttwelvemonths4618 = \"No\")",
                   "ActionCmds": [
                     {
                       "ActionCmd": "LoadingPercent, DTH, 'LOADING: 50% due to BMI 17 or <18', 50.0000%, '', 567",
                       "ParentNode": null
                     }
                   ]
                 }
               ],
               "Name": "4618",
               "Text": "Have you experienced any unexplained weight loss of more than 3kg or 7 lbs in the last 12 months?",
               "HelpText": null,
               "InputCaptureRules": {},
               "Tag": "Haveyouexperiencedanyunexplainedweightlossofmorethanthreekgorsevenlbsinthelasttwelvemonths4618",
               "IsRoot": false,
               "IsOptional": false,
               "IsLabel": false,
               "Note": null,
               "HasPlaceHolderInText": false,
               "Benefits": [
                 "DTH",
                 "TPD",
                 "TRA"
               ],
               "Style": null,
               "IsConfirmationRequired": false,
               "Nodes": [
                 {
                   "Actions": [],
                   "Name": "4619",
                   "Text": "How much weight have you lost?",
                   "HelpText": null,
                   "InputCaptureRules": {},
                   "Tag": "Howmuchweighthaveyoulost4619",
                   "IsRoot": false,
                   "IsOptional": false,
                   "IsLabel": false,
                   "Note": null,
                   "HasPlaceHolderInText": false,
                   "Benefits": [
                     "DTH",
                     "TPD",
                     "TRA"
                   ],
                   "Style": null,
                   "IsConfirmationRequired": false,
                   "Nodes": []
                 },
                 {
                   "Actions": [],
                   "Name": "4620",
                   "Text": "Did you consult a health professional regarding your weight loss?",
                   "HelpText": null,
                   "InputCaptureRules": {},
                   "Tag": "Didyouconsultahealthprofessionalregardingyourweightloss4620",
                   "IsRoot": false,
                   "IsOptional": false,
                   "IsLabel": false,
                   "Note": null,
                   "HasPlaceHolderInText": false,
                   "Benefits": [
                     "DTH",
                     "TPD",
                     "TRA"
                   ],
                   "Style": null,
                   "IsConfirmationRequired": false,
                   "Nodes": []
                 },
                 {
                   "Actions": [],
                   "Name": "4621",
                   "Text": "What investigations or treatment was recommended/performed?",
                   "HelpText": null,
                   "InputCaptureRules": {},
                   "Tag": "Whatinvestigationsortreatmentwasrecommendedperformed4621",
                   "IsRoot": false,
                   "IsOptional": false,
                   "IsLabel": false,
                   "Note": null,
                   "HasPlaceHolderInText": false,
                   "Benefits": [
                     "DTH",
                     "TPD",
                     "TRA"
                   ],
                   "Style": null,
                   "IsConfirmationRequired": false,
                   "Nodes": []
                 },
                 {
                   "Actions": [],
                   "Name": "4622",
                   "Text": "If you have had these investigations what were the results?",
                   "HelpText": null,
                   "InputCaptureRules": {},
                   "Tag": "Ifyouhavehadtheseinvestigationswhatweretheresults4622",
                   "IsRoot": false,
                   "IsOptional": false,
                   "IsLabel": false,
                   "Note": null,
                   "HasPlaceHolderInText": false,
                   "Benefits": [
                     "DTH",
                     "TPD",
                     "TRA"
                   ],
                   "Style": null,
                   "IsConfirmationRequired": false,
                   "Nodes": []
                 }
               ]
             }
           ]
         },
         {
           "Actions": [
             {
               "Rule": "(Haveyouweighedyourselfinthepastthreemonths4623 = \"Yes\") AND (Smoker = \"Non Smoker\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "LoadingPercent, TRA, 'LOADING: 100% due to BMI 33 or <38', 100.0000%, '', 568",
                   "ParentNode": null
                 },
                 {
                   "ActionCmd": "LoadingPercent, DTH, 'LOADING: 50% due to BMI 33 or <38', 50.0000%, '', 569",
                   "ParentNode": null
                 }
               ]
             },
             {
               "Rule": "(Haveyouweighedyourselfinthepastthreemonths4623 = \"Yes\") AND (Smoker = \"Smoker\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "Outcome, Decline, TRA, 'due to BMI >= 33 & BMI < 38 and Smoker', 1071",
                   "ParentNode": null
                 },
                 {
                   "ActionCmd": "LoadingPercent, DTH, 'LOADING: 75% due to BMI 33 or <38 and being a smoker', 75.0000%, '', 570",
                   "ParentNode": null
                 }
               ]
             },
             {
               "Rule": "(Haveyouweighedyourselfinthepastthreemonths4623 = \"No\") AND (Smoker = \"Non Smoker\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "LoadingPercent, TRA, 'LOADING: 100% due to BMI 33 or <38', 100.0000%, '', 568",
                   "ParentNode": null
                 },
                 {
                   "ActionCmd": "LoadingPercent, DTH, 'LOADING: 50% due to BMI 33 or <38', 50.0000%, '', 569",
                   "ParentNode": null
                 }
               ]
             },
             {
               "Rule": "(Haveyouweighedyourselfinthepastthreemonths4623 = \"No\") AND (Smoker = \"Smoker\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "Outcome, Decline, TRA, 'due to BMI >= 33 & BMI < 38 and Smoker', 1071",
                   "ParentNode": null
                 },
                 {
                   "ActionCmd": "LoadingPercent, DTH, 'LOADING: 75% due to BMI 33 or <38 and being a smoker', 75.0000%, '', 570",
                   "ParentNode": null
                 }
               ]
             }
           ],
           "Name": "4623",
           "Text": "Have you weighed yourself in the past 3 months?",
           "HelpText": null,
           "InputCaptureRules": {},
           "Tag": "Haveyouweighedyourselfinthepastthreemonths4623",
           "IsRoot": false,
           "IsOptional": false,
           "IsLabel": false,
           "Note": null,
           "HasPlaceHolderInText": false,
           "Benefits": [
             "DTH",
             "TRA"
           ],
           "Style": null,
           "IsConfirmationRequired": false,
           "Nodes": []
         },
         {
           "Actions": [
             {
               "Rule": "(Haveyouweighedyourselfinthepastthreemonths4626 = \"Yes\") AND (Smoker = \"Non Smoker\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "LoadingPercent, DTH, 'LOADING: 75% due to BMI 38 or <39', 75.0000%, '', 573",
                   "ParentNode": null
                 }
               ]
             },
             {
               "Rule": "(Haveyouweighedyourselfinthepastthreemonths4626 = \"Yes\") AND (Smoker = \"Smoker\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "LoadingPercent, DTH, 'LOADING: 100% due to BMI 38 or <39 and being a smoker', 100.0000%, '', 571",
                   "ParentNode": null
                 }
               ]
             },
             {
               "Rule": "(Haveyouweighedyourselfinthepastthreemonths4626 = \"No\") AND (Smoker = \"Non Smoker\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "LoadingPercent, DTH, 'LOADING: 100% due to BMI 38 or <39', 100.0000%, '', 574",
                   "ParentNode": null
                 }
               ]
             },
             {
               "Rule": "(Haveyouweighedyourselfinthepastthreemonths4626 = \"No\") AND (Smoker = \"Smoker\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "LoadingPercent, DTH, 'LOADING: 125% due to BMI 38 or <39 and being a smoker', 125.0000%, '', 572",
                   "ParentNode": null
                 }
               ]
             }
           ],
           "Name": "4626",
           "Text": "Have you weighed yourself in the past 3 months?",
           "HelpText": null,
           "InputCaptureRules": {},
           "Tag": "Haveyouweighedyourselfinthepastthreemonths4626",
           "IsRoot": false,
           "IsOptional": false,
           "IsLabel": false,
           "Note": null,
           "HasPlaceHolderInText": false,
           "Benefits": [
             "DTH",
             "TRA"
           ],
           "Style": null,
           "IsConfirmationRequired": false,
           "Nodes": []
         },
         {
           "Actions": [
             {
               "Rule": "(Haveyouweighedyourselfinthepastthreemonths4629 = \"Yes\") AND (Smoker = \"Non Smoker\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "LoadingPercent, DTH, 'LOADING: 100% due to BMI 39 or <=40', 100.0000%, '', 575",
                   "ParentNode": null
                 }
               ]
             },
             {
               "Rule": "(Haveyouweighedyourselfinthepastthreemonths4629 = \"Yes\") AND (Smoker = \"Smoker\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "LoadingPercent, DTH, 'LOADING: 125% due to BMI 39 or <=40 and being a smoker', 125.0000%, '', 576",
                   "ParentNode": null
                 }
               ]
             },
             {
               "Rule": "(Haveyouweighedyourselfinthepastthreemonths4629 = \"No\") AND (Smoker = \"Non Smoker\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "LoadingPercent, DTH, 'LOADING: 100% due to BMI 39 or <=40', 100.0000%, '', 575",
                   "ParentNode": null
                 }
               ]
             },
             {
               "Rule": "(Haveyouweighedyourselfinthepastthreemonths4629 = \"No\") AND (Smoker = \"Smoker\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "LoadingPercent, DTH, 'LOADING: 125% due to BMI 39 or <=40 and being a smoker', 125.0000%, '', 576",
                   "ParentNode": null
                 }
               ]
             }
           ],
           "Name": "4629",
           "Text": "Have you weighed yourself in the past 3 months?",
           "HelpText": null,
           "InputCaptureRules": {},
           "Tag": "Haveyouweighedyourselfinthepastthreemonths4629",
           "IsRoot": false,
           "IsOptional": false,
           "IsLabel": false,
           "Note": null,
           "HasPlaceHolderInText": false,
           "Benefits": [
             "DTH",
             "TRA"
           ],
           "Style": null,
           "IsConfirmationRequired": false,
           "Nodes": []
         }
       ],
       "IsRoot": true,
       "Actions": [
         {
           "Rule": "(BMI >= 16) AND (BMI < 17)",
           "ActionCmds": [
             {
               "ActionCmd": "OpenNode 4614",
               "ParentNode": null
             }
           ]
         },
         {
           "Rule": "(BMI >= 17) AND (BMI < 18)",
           "ActionCmds": [
             {
               "ActionCmd": "OpenNode 4617",
               "ParentNode": null
             }
           ]
         },
         {
           "Rule": "(BMI >= 33) AND (BMI < 38)",
           "ActionCmds": [
             {
               "ActionCmd": "OpenNode 4623",
               "ParentNode": null
             }
           ]
         },
         {
           "Rule": "(BMI >= 38) AND (BMI < 39)",
           "ActionCmds": [
             {
               "ActionCmd": "OpenNode 4626",
               "ParentNode": null
             },
             {
               "ActionCmd": "Outcome, Decline, TRA, 'due to BMI >= 38 & BMI < 39', 1072",
               "ParentNode": null
             }
           ]
         },
         {
           "Rule": "(BMI >= 39) AND (BMI <= 40)",
           "ActionCmds": [
             {
               "ActionCmd": "OpenNode 4629",
               "ParentNode": null
             },
             {
               "ActionCmd": "Outcome, Decline, TRA, 'due to BMI >= 39 & BMI <= 40', 1073",
               "ParentNode": null
             }
           ]
         },
         {
           "Rule": "(BMI > 0) AND (BMI < 16)",
           "ActionCmds": [
             {
               "ActionCmd": "Outcome, Decline, DTH, 'due to BMI < 16.0', 1067",
               "ParentNode": null
             },
             {
               "ActionCmd": "Outcome, Decline, TRA, 'due to BMI < 16.0', 1067",
               "ParentNode": null
             }
           ]
         },
         {
           "Rule": "(BMI > 40)",
           "ActionCmds": [
             {
               "ActionCmd": "Outcome, Decline, DTH, 'due to BMI > 40', 1074",
               "ParentNode": null
             },
             {
               "ActionCmd": "Outcome, Decline, TRA, 'due to BMI > 40', 1074",
               "ParentNode": null
             }
           ]
         }
       ]
     },
     {
       "Name": "AIDS declaration",
       "Nodes": [
         {
           "Actions": [
             {
               "Rule": "(HaveyoutestedpositiveforHIVorAIDSorareyouawaitingtheresultsofsuchatest4632 = \"Yes\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "Outcome, Decline, DTH, 'Tested positive for / waiting for a test result for : HIV or AIDS', 1157",
                   "ParentNode": null
                 },
                 {
                   "ActionCmd": "Outcome, Decline, TRA, 'Tested positive for / waiting for a test result for : HIV or AIDS', 1157",
                   "ParentNode": null
                 }
               ]
             }
           ],
           "Name": "4632",
           "Text": "Have you tested positive for HIV or AIDS or are you awaiting the results of such a test?",
           "HelpText": "HIV stands for :HumanImmunodeficiency Virus.<br/> <br/>AIDS stands for :Acquired Immune DeficiencySyndrome",
           "InputCaptureRules": {},
           "Tag": "HaveyoutestedpositiveforHIVorAIDSorareyouawaitingtheresultsofsuchatest4632",
           "IsRoot": true,
           "IsOptional": false,
           "IsLabel": false,
           "Note": null,
           "HasPlaceHolderInText": false,
           "Benefits": [
             "DTH",
             "TRA"
           ],
           "Style": null,
           "IsConfirmationRequired": false,
           "Nodes": []
         }
       ],
       "IsRoot": true,
       "Actions": []
     },
     {
       "Name": "Travel",
       "Nodes": [
         {
           "Actions": [
             {
               "Rule": "(InthenexttwelvemonthsdoyouhavedefiniteplanstotraveloutsideofCanadaforanypurposeformorethanthirtydaysintotalYoudontneedtotellusabouttraveltotheUSAifitslessthansixmonths5274 = \"Yes\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "OpenNode 5275",
                   "ParentNode": null
                 }
               ]
             }
           ],
           "Name": "5274",
           "Text": "In the next 12 months, do you have definite plans to travel outside of Canada, for any purpose, for more than 30 days in total? You don't need to tell us about travel to the USA if it's less than 6 months.",
           "HelpText": "'Definite plans' means: booked or will be booking travel  '30 days in total' means: the total time to be spent outside Canada over the next 12 months (including multiple trips).",
           "InputCaptureRules": {},
           "Tag": "InthenexttwelvemonthsdoyouhavedefiniteplanstotraveloutsideofCanadaforanypurposeformorethanthirtydaysintotalYoudontneedtotellusabouttraveltotheUSAifitslessthansixmonths5274",
           "IsRoot": true,
           "IsOptional": false,
           "IsLabel": false,
           "Note": null,
           "HasPlaceHolderInText": false,
           "Benefits": [
             "DTH",
             "TRA"
           ],
           "Style": null,
           "IsConfirmationRequired": false,
           "Nodes": [
             {
               "Actions": [
                 {
                   "Rule": "(Whichcountrysdoyouintendtotravelto5275 = \"Yes\")",
                   "ActionCmds": [
                     {
                       "ActionCmd": "OpenNode 5231",
                       "ParentNode": null
                     }
                   ]
                 },
                 {
                   "Rule": "(Whichcountrysdoyouintendtotravelto5275 = \"No\")",
                   "ActionCmds": [
                     {
                       "ActionCmd": "OpenNode 5277",
                       "ParentNode": null
                     }
                   ]
                 }
               ],
               "Name": "5275",
               "Text": "Which country(s) do you intend  to travel to?",
               "HelpText": "Do any locations appear below?",
               "InputCaptureRules": {},
               "Tag": "Whichcountrysdoyouintendtotravelto5275",
               "IsRoot": false,
               "IsOptional": false,
               "IsLabel": false,
               "Note": {
                 "Format": "HTML",
                 "Items": [
                   {
                     "Style": "",
                     "Text": "<style type=\"text/css\"> .questionnote td{width: 375px; vertical-align: top; text-align: left;}.questionnote table{border-collapse: collapse; border:1; font-size:0.9em; cellpadding:0; cellspacing=0;}</style><div class=\"questionnote\"><table border=\"1\"> <tbody><tr><td>Afghanistan</td><td>Mali</td></tr><tr><td>Burundi</td><td>Nigeria</td></tr><tr><td>Central African Republic</td><td>Pakistan</td></tr><tr><td>Chad</td><td>Sierra Leone</td></tr><tr><td>Cote d'lvoire / Ivory Coast</td><td>Somalia</td></tr><tr><td>Democratic Republic of the Congo (Zaire)</td><td>Sudan</td></tr><tr><td>Djibouti</td><td>Syria</td></tr><tr><td>Guinea</td><td>Tunisia</td></tr><tr><td>Haiti</td><td>Ukraine</td></tr><tr><td>Iran</td><td>Yemen</td></tr><tr><td>Iraq</td><td>Zaire</td></tr><tr><td>Liberia</td><td>Zimbabwe</td></tr></tbody> </table></div>"
                   }
                 ]
               },
               "HasPlaceHolderInText": false,
               "Benefits": [
                 "DTH",
                 "TRA"
               ],
               "Style": null,
               "IsConfirmationRequired": false,
               "Nodes": []
             }
           ]
         },
         {
           "Actions": [
             {
               "Rule": "(Howmanydaysintotalwillyoubestayingtherefor5231 = \"Less than or equal to 30 days in total\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "OpenNode 5276",
                   "ParentNode": null
                 }
               ]
             },
             {
               "Rule": "(Howmanydaysintotalwillyoubestayingtherefor5231 = \"More than 30 days in total\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "Outcome, Decline, DTH, 'Travel to declined destination(s)', 1179",
                   "ParentNode": null
                 },
                 {
                   "ActionCmd": "Outcome, Decline, TRA, 'Travel to declined destination(s)', 1179",
                   "ParentNode": null
                 }
               ]
             }
           ],
           "Name": "5231",
           "Text": "How many days in total will you be staying there for?",
           "HelpText": "This question applies to the combined total number of days for the countries on the above list",
           "InputCaptureRules": {},
           "Tag": "Howmanydaysintotalwillyoubestayingtherefor5231",
           "IsRoot": false,
           "IsOptional": false,
           "IsLabel": false,
           "Note": null,
           "HasPlaceHolderInText": false,
           "Benefits": [
             "DTH",
             "TRA"
           ],
           "Style": null,
           "IsConfirmationRequired": false,
           "Nodes": [
             {
               "Actions": [
                 {
                   "Rule": "(Whichcountrysdoyouintendtotravelto5276 = \"Yes\")",
                   "ActionCmds": [
                     {
                       "ActionCmd": "OpenNode 5233",
                       "ParentNode": null
                     }
                   ]
                 }
               ],
               "Name": "5276",
               "Text": "Which country(s) do you intend to travel to?",
               "HelpText": "Do any of the locations appear below?",
               "InputCaptureRules": {},
               "Tag": "Whichcountrysdoyouintendtotravelto5276",
               "IsRoot": false,
               "IsOptional": false,
               "IsLabel": false,
               "Note": {
                 "Format": "HTML",
                 "Items": [
                   {
                     "Style": "",
                     "Text": "<style type=\"text/css\"> .questionnote td{width: 375px; vertical-align: top; text-align: left;}.questionnote table{border-collapse: collapse; border:1; font-size:0.9em; cellpadding:0; cellspacing=0;}</style><div class=\"questionnote\"><table border=\"1\"> <tbody><tr><td>Algeria</td><td>Indonesia (excluding Bali) </td></tr><tr><td>Angola</td><td>Lebanon</td></tr><tr><td>Cameroon</td><td>Mauritania</td></tr><tr><td>Columbia</td><td>Niger</td></tr><tr><td>Ecuador</td><td>Russia</td></tr><tr><td>Eritrea</td><td>Rwanda</td></tr><tr><td>Ethiopia</td><td>Sri Lanka</td></tr><tr><td>Georgia</td><td>Uganda</td></tr><tr><td>Honduras</td><td></td></tr></tbody> </table></div>"
                   }
                 ]
               },
               "HasPlaceHolderInText": false,
               "Benefits": [
                 "DTH",
                 "TRA"
               ],
               "Style": null,
               "IsConfirmationRequired": false,
               "Nodes": []
             }
           ]
         },
         {
           "Actions": [
             {
               "Rule": "(Howmanydaysintotalwillyoubestayingtherefor5233 = \"More than 30 days in total\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "Exclusion, DTH, 'No benefit amount will be payable for death, injury or disability to the life insured caused either directly or indirectly by violent acts, including but not limited to, acts of war, invasion, hostilities (whether war is declared or not), civil war, rebellion, revolution, or taking part in a riot or a civil commotion.', 479",
                   "ParentNode": null
                 }
               ]
             }
           ],
           "Name": "5233",
           "Text": "How many days in total will you be staying there for?",
           "HelpText": "This question applies to countries on list # 2",
           "InputCaptureRules": {},
           "Tag": "Howmanydaysintotalwillyoubestayingtherefor5233",
           "IsRoot": false,
           "IsOptional": false,
           "IsLabel": false,
           "Note": null,
           "HasPlaceHolderInText": false,
           "Benefits": [
             "DTH",
             "TRA"
           ],
           "Style": null,
           "IsConfirmationRequired": false,
           "Nodes": []
         },
         {
           "Actions": [
             {
               "Rule": "(Whichcountrysdoyouintendtotravelto5277 = \"Yes\")",
               "ActionCmds": [
                 {
                   "ActionCmd": "OpenNode 5235",
                   "ParentNode": null
                 }
               ]
             }
           ],
           "Name": "5277",
           "Text": "Which country(s) do you intend to travel to?",
           "HelpText": "Do any of the locations appear below?",
           "InputCaptureRules": {},
           "Tag": "Whichcountrysdoyouintendtotravelto5277",
           "IsRoot": false,
           "IsOptional": false,
           "IsLabel": false,
           "Note": {
             "Format": "HTML",
             "Items": [
               {
                 "Style": "",
                 "Text": "<style type=\"text/css\"> .questionnote td{width: 375px; vertical-align: top; text-align: left;}.questionnote table{border-collapse: collapse; border:1; font-size:0.9em; cellpadding:0; cellspacing=0;}</style><div class=\"questionnote\"><table border=\"1\"> <tbody><tr><td>Algeria</td><td>Indonesia (excluding Bali) </td></tr><tr><td>Angola</td><td>Lebanon</td></tr><tr><td>Cameroon</td><td>Mauritania</td></tr><tr><td>Columbia</td><td>Niger</td></tr><tr><td>Ecuador</td><td>Russia</td></tr><tr><td>Eritrea</td><td>Rwanda</td></tr><tr><td>Ethiopia</td><td>Sri Lanka</td></tr><tr><td>Georgia</td><td>Uganda</td></tr><tr><td>Honduras</td><td></td></tr></tbody> </table></div>"
               }
             ]
           },
           "HasPlaceHolderInText": false,
           "Benefits": [
             "DTH",
             "TRA"
           ],
           "Style": null,
           "IsConfirmationRequired": false,
           "Nodes": [
             {
               "Actions": [
                 {
                   "Rule": "(HowmanydaysintotalwillyoubestayingthereforThisquestionappliestothecombinedtotalnumberofdaysforthecountriesontheabovelist5235 = \"More than 30 days in total\")",
                   "ActionCmds": [
                     {
                       "ActionCmd": "Exclusion, DTH, 'No benefit amount will be payable for death, injury or disability to the life insured caused either directly or indirectly by violent acts, including but not limited to, acts of war, invasion, hostilities (whether war is declared or not), civil war, rebellion, revolution, or taking part in a riot or a civil commotion.', 479",
                       "ParentNode": null
                     },
                     {
                       "ActionCmd": "Exclusion, TRA, 'No benefit amount will be payable for death, injury or disability to the life insured caused either directly or indirectly by violent acts, including but not limited to, acts of war, invasion, hostilities (whether war is declared or not), civil war, rebellion, revolution, or taking part in a riot or a civil commotion.', 479",
                       "ParentNode": null
                     }
                   ]
                 }
               ],
               "Name": "5235",
               "Text": "How many days in total will you be staying there for? This question applies to the combined total number of days for the countries on the above list",
               "HelpText": null,
               "InputCaptureRules": {},
               "Tag": "HowmanydaysintotalwillyoubestayingthereforThisquestionappliestothecombinedtotalnumberofdaysforthecountriesontheabovelist5235",
               "IsRoot": false,
               "IsOptional": false,
               "IsLabel": false,
               "Note": null,
               "HasPlaceHolderInText": false,
               "Benefits": [
                 "DTH",
                 "TRA"
               ],
               "Style": null,
               "IsConfirmationRequired": false,
               "Nodes": []
             }
           ]
         }
       ],
       "IsRoot": true,
       "Actions": []
     },
     {
       "Name": "NewSection",
       "Nodes": [
         {
           "Actions": [
             {
               "Rule": "",
               "ActionCmds": [
                 {
                   "ActionCmd": "",
                   "ParentNode": ""
                 }
               ]
             }
           ],
           "Name": "NewSectionNode",
           "Text": "NewSectionNode",
           "HelpText": "",
           "InputCaptureRules": {
             "Min": 0,
             "Max": 0
           },
           "Tag": "NewSectionNode",
           "IsRoot": true,
           "IsOptional": false,
           "IsLabel": false,
           "Note": {
             "Format": "",
             "Items": [
               {
                 "Style": "",
                 "Text": ""
               }
             ]
           },
           "HasPlaceHolderInText": false,
           "Benefits": [
             ""
           ],
           "Style": "",
           "IsConfirmationRequired": false,
           "Nodes": [
             {
               "Actions": [
                 {
                   "Rule": "",
                   "ActionCmds": [
                     {
                       "ActionCmd": "",
                       "ParentNode": ""
                     }
                   ]
                 }
               ],
               "Name": "ChildDepthLevel0",
               "Text": "ChildDepthLevel0",
               "HelpText": "",
               "InputCaptureRules": {
                 "Min": 0,
                 "Max": 0
               },
               "Tag": "ChildDepthLevel0",
               "IsRoot": true,
               "IsOptional": false,
               "IsLabel": false,
               "Note": {
                 "Format": "",
                 "Items": [
                   {
                     "Style": "",
                     "Text": ""
                   }
                 ]
               },
               "HasPlaceHolderInText": false,
               "Benefits": [
                 ""
               ],
               "Style": "",
               "IsConfirmationRequired": false,
               "Nodes": [
                 {
                   "Actions": [
                     {
                       "Rule": "",
                       "ActionCmds": [
                         {
                           "ActionCmd": "",
                           "ParentNode": ""
                         }
                       ]
                     }
                   ],
                   "Name": "ChildDepthLevel1",
                   "Text": "ChildDepthLevel1",
                   "HelpText": "",
                   "InputCaptureRules": {
                     "Min": 0,
                     "Max": 0
                   },
                   "Tag": "ChildDepthLevel1",
                   "IsRoot": true,
                   "IsOptional": false,
                   "IsLabel": false,
                   "Note": {
                     "Format": "",
                     "Items": [
                       {
                         "Style": "",
                         "Text": ""
                       }
                     ]
                   },
                   "HasPlaceHolderInText": false,
                   "Benefits": [
                     ""
                   ],
                   "Style": "",
                   "IsConfirmationRequired": false,
                   "Nodes": [
                     {
                       "Actions": [
                         {
                           "Rule": "",
                           "ActionCmds": [
                             {
                               "ActionCmd": "",
                               "ParentNode": ""
                             }
                           ]
                         }
                       ],
                       "Name": "ChildDepthLevel2",
                       "Text": "ChildDepthLevel2",
                       "HelpText": "",
                       "InputCaptureRules": {
                         "Min": 0,
                         "Max": 0
                       },
                       "Tag": "ChildDepthLevel2",
                       "IsRoot": true,
                       "IsOptional": false,
                       "IsLabel": false,
                       "Note": {
                         "Format": "",
                         "Items": [
                           {
                             "Style": "",
                             "Text": ""
                           }
                         ]
                       },
                       "HasPlaceHolderInText": false,
                       "Benefits": [
                         ""
                       ],
                       "Style": "",
                       "IsConfirmationRequired": false,
                       "Nodes": [
                         {
                           "Actions": [
                             {
                               "Rule": "",
                               "ActionCmds": [
                                 {
                                   "ActionCmd": "",
                                   "ParentNode": ""
                                 }
                               ]
                             }
                           ],
                           "Name": "ChildDepthLevel3",
                           "Text": "ChildDepthLevel3",
                           "HelpText": "",
                           "InputCaptureRules": {
                             "Min": 0,
                             "Max": 0
                           },
                           "Tag": "ChildDepthLevel3",
                           "IsRoot": true,
                           "IsOptional": false,
                           "IsLabel": false,
                           "Note": {
                             "Format": "",
                             "Items": [
                               {
                                 "Style": "",
                                 "Text": ""
                               }
                             ]
                           },
                           "HasPlaceHolderInText": false,
                           "Benefits": [
                             ""
                           ],
                           "Style": "",
                           "IsConfirmationRequired": false,
                           "Nodes": [
                             {
                               "Actions": [
                                 {
                                   "Rule": "",
                                   "ActionCmds": [
                                     {
                                       "ActionCmd": "",
                                       "ParentNode": ""
                                     }
                                   ]
                                 }
                               ],
                               "Name": "ChildDepthLevel4",
                               "Text": "ChildDepthLevel4",
                               "HelpText": "",
                               "InputCaptureRules": {
                                 "Min": 0,
                                 "Max": 0
                               },
                               "Tag": "ChildDepthLevel4",
                               "IsRoot": true,
                               "IsOptional": false,
                               "IsLabel": false,
                               "Note": {
                                 "Format": "",
                                 "Items": [
                                   {
                                     "Style": "",
                                     "Text": ""
                                   }
                                 ]
                               },
                               "HasPlaceHolderInText": false,
                               "Benefits": [
                                 ""
                               ],
                               "Style": "",
                               "IsConfirmationRequired": false,
                               "Nodes": []
                             }
                           ]
                         }
                       ]
                     }
                   ]
                 }
               ]
             }
           ]
         }
       ],
       "IsRoot": false,
       "Actions": [
         {
           "Rule": "",
           "ActionCmds": [
             {
               "ActionCmd": "",
               "ParentNode": ""
             }
           ]
         }
       ]
     }
   ]
 }



dotnet-csharpdotnet-cli
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered suryapsingh2019 commented

You don’t show how you are parsing the json, and unlike xml which is a true tree structure, json when parsed to nodes has rules for inserting values.

For instance, a node must either be a value (which do not have children), an object specifier, or an array. For example the following json

“Hello”

You can not append nodes, you must transform the root node into a array (a value node can not be translated to an object property with out generating a property name. So to append node the first step is to convert to an array

[“Hello”]

Now you can append a value, but not a property, say “count”:1, to do this you need to append an object, so you need to convert the property to an object

{“count”:1}

Now you can append the new object to the array

[“Hello”,{“count”:1}]


So if you look for text, it’s either going to a string value in an array, which you could append to, the string value of a property, which has no children, and to append you need a new unique property name to add to the oarent object, so you can add the new string value.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I have added my code of using recursion

0 Votes 0 ·