title: Converting datatable into hierarchical data structure (JSON) using C#
body: <p>I am executing a SQL query into datatable. The query can return multiple columns. The result is in key value format and represent hierarchical data. See the below screenshot. </p>
  
  <p><a href="https://i.stack.imgur.com/f09La.png" rel="noreferrer"><img src="https://i.stack.imgur.com/f09La.png" alt="enter image description here"></a></p>
  
  <p>The image shows 3 parts. First the data, then the hierarchical representation of data and JSON equivalent. </p>
  
  <p>Currently the image shows 4 level of data, but we can have 6-7 levels of data. The format will remain same but the number of columns can change. </p>
  
  <p>How can i get the desired result using C#? ? I  know it is basic programming but I am having hard time with it. </p>