Share via

JSON Format WebAPI Entity Framework

TheCoder 91 Reputation points
2023-01-19T16:31:09.4066667+00:00

Currently the JSON I'm using looks like this:

The JSON file is huge so I'm only showing the first few rows in the file so not all data is shown. I'd like to get this JSON structured so I can use in a TreeView menu so I'd like to see get the out put to be: I'm getting the data using EF Core, C# in a WebAPI.

OR will this JSON work and I just need to figure out how to build the TreeView navigation from it?

New:

   Lot

     Chevy

      Ford

Used:

    Lot

        Ford

    back  lot

         Ford
[
    {
       "node" : "New",
       "node1" : 
        [
           {
              "node2" : 
               [
                 { 
                   "node2" : "Chevy",
                    "location" : [ 
                           "lot" 
                        ]
                     }
                 ]
           },
          { "node2" : [ 
                { 
                   "node2" : "Ford",
                    "location" : [
                       "lot"
                      ] 
                  }
               ]
           }
  
        ]

     },
     {
       "node" : "Used",
       "node1" : 
        [
           {
              "node2" : 
               [
                 { 
                   "node2" : "Ford",
                    "location" : [ 
                           "back lot" 
                        ]
                     }
                 ]
           },
          { "node2" : [ 
                { 
                   "node2" : "Ford",
                    "location" : [
                       "lot"
                      ] 
                  }
               ]
           }
  
        ]

     }  
]
   {
      "node" : "New" ,
      "node1" : [
       {
         "node2" : [ 
          {
             "node2" : "Chevy",
             "location" :   [ "lot" ]
        }] 
       }  
   ]},
   
 {

      "node" : "New" ,

      "node1" : [

       {

         "node2" : [ 

          {

             "node2" : "Chevy",

             "location" :   [ "lot" ]

        }] 

       }  

   ]},
]
Developer technologies | .NET | Entity Framework Core
Developer technologies | ASP.NET | ASP.NET API
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.


1 answer

Sort by: Most helpful
  1. Naimish Makwana 175 Reputation points
    2023-01-19T17:57:38.85+00:00

    Hello @TheCoder

    Your JSON look's OK.

    For create Treeview from JSON. Please check below link.

    [https://www.youtube.com/watch?v=f7tHyxWd_UA

    Thanks

    Naimish Makwana

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.