how can I read specific data from a JSON file and use that data again in Javascript.
Example: I have a .JSON file that has thousands of records of planets outside our solar system. There's a column in JSON (well, in CVS at least when I converted it to JSON) that has all that information about all of these planets calculated in distance in parsec.
I want to be able to calculate what the average is of all of these planets and alert this number through simple javascript.
This is how these planets are listed in JSON:
"Distance [pc]": 110.62,
"Effective Temperature [K]": 4742,
"Date of Last Update": "5/14/2014"
I am very new to JSON so this might be an easy enough answer for JSON experts to answer. Hope you can help, thanks!
PS: I added the JSON file thinking it would help you in understanding and answering the question. Here's a temporary URL to it I uploaded.
EDIT:
Here's more of a chunk of the JSON code
[
{
"rowid": 1,
"Host name": "11 Com",
"Number of Planets in System": 1,
"Planet Mass or M*sin(i)[Jupiter mass]": 19.4,
"Planet Radius [Jupiter radii]": null,
"Planet Density [g": {
"cm**3]": null
},
"Distance [pc]": 110.62,
"Effective Temperature [K]": 4742,
"Date of Last Update": "5/14/2014"
},
{
"rowid": 2,
"Host name": "11 UMi",
"Number of Planets in System": 1,
"Planet Mass or M*sin(i)[Jupiter mass]": 10.5,
"Planet Radius [Jupiter radii]": null,
"Planet Density [g": {
"cm**3]": null
},
"Distance [pc]": 119.47,
"Effective Temperature [K]": 4340,
"Date of Last Update": "5/14/2014"
},
{
"rowid": 3,
"Host name": "14 And",
"Number of Planets in System": 1,
"Planet Mass or M*sin(i)[Jupiter mass]": 4.8,
"Planet Radius [Jupiter radii]": null,
"Planet Density [g": {
"cm**3]": null
},
"Distance [pc]": 76.39,
"Effective Temperature [K]": 4813,
"Date of Last Update": "5/14/2014"
},
{
"rowid": 4,
"Host name": "14 Her",
"Number of Planets in System": 1,
"Planet Mass or M*sin(i)[Jupiter mass]": 4.64,
"Planet Radius [Jupiter radii]": null,
"Planet Density [g": {
"cm**3]": null
},
"Distance [pc]": 18.15,
"Effective Temperature [K]": 5311,
"Date of Last Update": "5/14/2014"
}]
enter code here