I am trying banging my head to filter json written below to get desired result.
[{
"Key": "EShSOKthupE=",
"ImageUrl": "path",
"Title": "ABC",
"CityId": 16,
"TimezoneShortName": "PYT",
"UtcHrsDiff": 8.5,
"PlaceKey": "QIZHdWOa77o=",
"PlaceName": "Shymala Hills Slums",
"Lat": 23.2424856,
"Long": 77.39488289999997,
"ActivityList": [ "Test Activity" ]
},
{
"Key": "NXLQpZAZT4M=",
"ImageUrl": "",
"Title": "ASAS",
"CityId": 17,
"TimezoneShortName": "AEST",
"UtcHrsDiff": 10,
"PlaceKey": "o4fAkahBzYY=",
"PlaceName": "ASAS",
"Lat": 12.9856503,
"Long": 77.60569269999996,
"ActivityList": [ "Adventure Sport" ]
}]
Now I want to get json like this from above json using lodash or undescore js.
[{
"PlaceKey": "QIZHdWOa77o=",
"PlaceName": "ABC",
"Lat": 23.2424856,
"Long": 77.39488289999997
},
{
"PlaceKey": "o4fAkahBzYY=",
"PlaceName": "ASAS",
"Lat": 12.9856503,
"Long": 77.60569269999996,
}]
Any help I can get on this?
Using lodash:
_.map(yourArray, (el => _.pick(el, ['PlaceKey', 'PlaceName', 'Lat', 'Long'])))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With