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" ]

        }] 

       }  

   ]},
]
Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
696 questions
C#
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.
10,292 questions
ASP.NET API
ASP.NET API
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
301 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Naimish Makwana 170 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