how to read location using javascript


<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>

www.codegrepper.com
www.stackoverflow.com

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);

www.codegrepper.com
www.stackoverflow.com

how to read if a person has send a message on discord.js


client.on('message', message => {
// this function can check whether the content of the message you pass is the same as this message
let filter = msg => {
return msg.content.toLowerCase() == message.content.toLowerCase() && // check if the content is the same (sort of)
msg.author == message.author; // check if the author is the same
}

message.channel.awaitMessages(filter, {
maxMatches: 1, // you only need that to happen once
time: 5 * 1000 // time is in milliseconds
}).then(collected => {
// this function will be called when a message matches you filter
}).catch(console.error);
});

www.codegrepper.com
www.stackoverflow.com

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

www.codegrepper.com
www.stackoverflow.com

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

www.codegrepper.com
www.stackoverflow.com

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>

www.codegrepper.com
www.stackoverflow.com