// Called from viewDidLoad
func setupMap() {
mapView.delegate = self
// BusStop implements the MKAnnotation protocol, I have an array of them
let routeCoordinates = busStops.map({ $0.coordinate })
let routeLine = MKPolyline(coordinates: routeCoordinates, count: routeCoordinates.count)
mapView.setVisibleMapRect(routeLine.boundingMapRect, animated: false)
mapView.add(routeLine)
}
// MARK: MKMapViewDelegate
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
if let polyline = overlay as? MKPolyline {
let polylineRenderer = MKPolylineRenderer(overlay: polyline)
polylineRenderer.strokeColor = .blue
polylineRenderer.lineWidth = 3
return polylineRenderer
}
return MKOverlayRenderer(overlay: overlay)
}
我想从这个对象访问classKey和status。
如何访问每个键值?
我试过这个{
"sachin.company": {
"classkey": "dotcompany",
"status": "available"
},
"sachin.com": {
"classkey": "domcno",
"status": "regthroughothers"
},
"sachin.co.in": {
"classkey": "thirdleveldotin",
"status": "regthroughothers"
},
"sachin.org": {
"classkey": "domorg",
"status": "regthroughothers"
},
"sachin.guru": {
"classkey": "dotguru",
"status": "available"
},
"sachin.sexy": {
"classkey": "dotsexy",
"status": "available"
},
"sachin.nettlds=asia": {
"status": "unknown"
}
}
,但这只创建了像var keys = Object.keys(response);
答案 0 :(得分:1)
$("#slack-time").click(function(e){
e.preventDefault();
chrome.tabs.query({currentWindow: true, active: true}, function (tab) {
chrome.tabs.update(tab.id, {url: 'http://www.facebook.com'});
});
})
答案 1 :(得分:0)
如果您想获得所有已定义的值
做如下,
var allValues = [];
var keys = Object.keys(parsedJson);
Object.values(parsedJson).forEach(function(x) {
Object.values(x).forEach(function(y){
this.allValues.push(y);
}, this);
}, this);
allValues
会给你你想要的东西。
感谢。