Skip to main content

data

 const jsonData = [

    {

        "id": 16,

        "city": "Segaon Tahsil",

        "city_status": "A",

        "area": []

    },

    {

        "id": 15,

        "city": "Hyderabad",

        "city_status": "A",

        "area": [

            {

                "id": 3,

                "highlighted_area": "Ameerpet-Hyderabad",

                "location": 15

            },

            {

                "id": 4,

                "highlighted_area": "Begumpet-Hyderabad",

                "location": 15

            },

            {

                "id": 6,

                "highlighted_area": "Khairatabad-Hyderabad",

                "location": 15

            },

            {

                "id": 7,

                "highlighted_area": "Punjagutta-Hyderabad",

                "location": 15

            }

        ]

    }

];


function extractLocations(data) {

    const locations = [];


    data.forEach(item => {

        if (item.city) {

            // Add city itself as a location

            locations.push({ location: item.city });

            // Add all highlighted areas if available

            item.area.forEach(areaItem => {

                if (areaItem.highlighted_area) {

                    locations.push({ location: areaItem.highlighted_area });

                }

            });

        }

    });


    return locations;

}


const locationData = extractLocations(jsonData);

console.log(locationData);


Comments

Popular posts from this blog

Delete put code

   <system.webServer>     <validation validateIntegratedModeConfiguration="false"/>     <modules runAllManagedModulesForAllRequests="true">         <remove name="WebDAVModule"/> <!-- ADD THIS -->     </modules>      <handlers>            <remove name="ExtensionlessUrlHandler-Integrated-4.0" />       <remove name="OPTIONSVerbHandler" />       <remove name="TRACEVerbHandler" />       <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />     </handlers></system.webServer>

WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive).

  WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive). Solution   < appSettings > < add key = "ValidationSettings:UnobtrusiveValidationMode" value = "None" /> </ appSettings >