<script>
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>
Category: read
how to read xml element in xml2js
var xml2js = require('xml2js');
var xml = "<config><test>Hello</test><data>SomeData</data></config>";
var extractedData = "";
var parser = new xml2js.Parser();
parser.parseString(xml, function(err,result){
//Extract the value from the data element
extractedData = result['config']['data'];
console.log(extractedData);
});
console.log("Note that you can't use value here if parseString is async; extractedData=", extractedData);
how to read 2 dimensional array in javascript
activities.forEach((activity) => {
activity.forEach((data) => {
console.log(data);
});
});
how to read an array in javascript in HTML5
<body>
<h1>Creating Arrays</h1>
<h2>Regular:</h2>
<script language="JavaScript">
// Create the array.
var Colors = new Array();
// Fill the array with data.
Colors[0] = "Blue";
Colors[1] = "Green";
Colors[2] = "Purple";
// Display the content onscreen.
document.write(Colors);
</script>
<h2>Condensed:</h2>
<script language="JavaScript">
// Create the array and fill it with data.
var Colors = new Array("Blue", "Green", "Purple");
// Display the content onscreen.
document.write(Colors);
</script>
<h2>Literal:</h2>
<script language="JavaScript">
// Create the array and fill it with data.
var Colors = ["Blue", "Green", "Purple"];
// Display the content onscreen.
document.write(Colors);
</script>
</body>
how to read json file in C#
JObject o1 = JObject.Parse(File.ReadAllText(@"c:videogames.json"));
// read JSON directly from a file
using (StreamReader file = File.OpenText(@"c:videogames.json"))
using (JsonTextReader reader = new JsonTextReader(file))
{
JObject o2 = (JObject)JToken.ReadFrom(reader);
}
//For any of the JSON parse, use the website
//http://json2csharp.com/
//(easiest way) to convert your JSON into
//C# class to deserialize your JSON into C# object.
public class FormatClass
{
public string JsonName { get; set; }
public string JsonPass { get; set; }
}
//Then use the JavaScriptSerializer (from System.Web.Script.Serialization),
// in case you don't want any third party DLL like newtonsoft.
public void Read()
{
using (StreamReader Filejosn = new StreamReader("Path.json"))
{
JavaScriptSerializer jss = new JavaScriptSerializer();
var Items = jss.Deserialize<FormatClass>(Filejosn.ReadToEnd());
// Add Code here :)
}
}
//by ahmed ashraf +201111490105
how to read json file in python
import json
with open('data.txt') as json_file:
data = json.load(json_file)
import json
with open('path_to_file/person.json') as f:
data = json.load(f)
print(data)
import json
with open('data.txt') as json_file:
data = json.load(json_file)
for p in data['people']:
print('Name: ' + p['name'])
print('Website: ' + p['website'])
print('From: ' + p['from'])
print('')
reading json file from python
how to read json file in python stack overflow
import json
with open('strings.json') as f:
d = json.load(f)
print(d)