So I have a JSON feed and i'm simply trying to print out some values.
My Javascript below sort of works. But it doesn't look very 'correct'. Is there a better way of doing this please?
JSON
{
"info":[
{
"lon":-2.1,
"lat":55.2
},
{
"lon":-2.12,
"lat":55.23
}
]
}
JavaScript
var jsonURL = "url here";
$.getJSON(jsonURL, function(json1) {
$.each(json1, function(key, data) {
$.each(data, function(key, data){
var latLng = new google.maps.LatLng(
data.lat, data.lon);
var marker = new google.maps.Marker({
position : latLng
});
marker.setMap(map);
});
});
});
JSON logging is the best format for storing your logs, and here's why. Usually, we log application data in a file. But we need a better framework. If we write logs as JSON, we can easily search fields with a JSON key.
The JSON format is ubiquitous and used everywhere from logging in web apps to message passing for microcontrollers. Thanks to its compact nature and it being easily readable by humans, JSON has become the de facto standard for sharing structured data.
To enable parsing JSON log, you add parse: json to a pipeline in the ClusterLogForwarder CR, as shown in the following example. When you enable parsing JSON logs by using parse: json , the CR copies the JSON-structured log entry in a structured field, as shown in the following example.
You know the "info" attribute exists and don't need a loop to get to it. The inner loop looks good.
$.getJSON(jsonURL, function(json1) {
$.each(json1.info, function(key, data){
var latLng = new google.maps.LatLng(
data.lat, data.lon);
var marker = new google.maps.Marker({
position : latLng
});
marker.setMap(map);
});
});
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