rajesh yadav

rajesh yadav

  • 1.6k
  • 82
  • 10.1k

i have got one json . i want to read it in following way

Feb 18 2020 3:51 AM
hi , ihave following json in mongo db.
 
i can get the rows from mongo db but then i have to do this in c# core.
 
id :1
/** * Paste one or more documents here */ { "nodeHierarchy": { "L1": "Mechanical" }, "weightage": { "$numberDouble": "100" }, "dateFrom": { "$date": { "$numberLong": "1581445800000" } }, "dateTo": { "$date": { "$numberLong": "1582914600000" } }, "WSID": "PRJ1", "scope": { "$numberDecimal": "1000" }, "IsLeafNode": false }
 
id :2
/** * Paste one or more documents here */ { "nodeHierarchy": { "L1": "Mechanical", "L2": "Act1" }, "weightage": { "$numberDouble": "100" }, "dateFrom": { "$date": { "$numberLong": "1581445800000" } }, "dateTo": { "$date": { "$numberLong": "1582914600000" } }, "WSID": "PRJ1", "scope": { "$numberDecimal": "1000" }, "IsLeafNode": true }
 
i have many rows in above formate, but i have take only two rows for brevity,
 
the first row is parent row which has "L1":mechanical, and second row is child of "mechanical" which is at "L2":"Act1"
 
this hierarchy could be at n level.
 
what i have to do is i have to get the child row the last row by filtering "IsleafNode"; true and then divide the weightage of child node with weightage of parent row, and then so on, till i get the top most parent.
 
note; u can suggest to change our json also.
 
how can do it in c# core.

Answers (4)