I am creating a Angular 2 application. My server side request returns me a JSON that will look like
[{"CountryId":1,"CountryCode":"IND","CountryName":"India","State":[]},
{"CountryId":2,"CountryCode":"AUS","CountryName":"Australia","State":[]}]
I need to display this in a dropdown. So I need to create a new JSON that will look like
[{"Label":"India","Value":"IND"},
{"Label":"Australia","Value":"AUS"}]
I dont want to write for loop as i will be using this in many places and i want it to be best possible in performance. Please let me know if there is any inbuilt function that can do this kind of JSON restructure.
forloop is exactly what you need (althoughmap()is nicer).