How can i extract jquery parameters from url?

207
March 06, 2019, at 11:00 PM

I need to extract the "data:" for station listed bellow from this url http://swe-sso.dlr.de/Ionospheric_Perturbations/Rate_Of_Change_Of_TEC_Index/mean_ROTI_Europe/latest/mean_ROTI_Europe.json

{
  "properties": {
    "rcv": "BUCU00ROU0_EUREF",
    "sat": "G24",
    "roti": 0.508,
    "azimuth_deg": 168.4,
    "elevation_deg": 20.99
  },
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [
      25.34,
      45.15
    ]
  }
}

"Data:" is the main index for stations data

what is the correct syntax to do that with js?

Answer 1

I assume you mean sat and not station, as that doesn't exist in your example. You could access it like this with JavaScript by assigning it to a variable:

var sat = yourJSONobj["properties"]["sat"]

Here's an example printing that object in that array:

yourJSON = { "properties":{ "rcv":"BUCU00ROU0_EUREF", "sat":"G24", "roti":0.508, "azimuth_deg":168.4, "elevation_deg":20.99 } }, { "type":"Feature", "geometry":{ "type":"Point", "coordinates":[ 25.34, 45.15 ] } } 
 
document.getElementById("json").innerHTML +=JSON.stringify(yourJSON["properties"]["sat"]);
<p id="json"></p>

edit: cleaned up code

Answer 2

I'm going to try to point you in the right direction here, but you'll need to still do some reading. To clarify, you appear to be asking how you can use jQuery to load some JSON data, and then pull out parts of it. I'm inferring this by looking at the URL you provided.

  1. First thing you'll want to know is how to get that JSON that's sitting behind the URL into a JavaScript object. You should look at http://api.jquery.com/jQuery.getJSON/ to get started there. That will tell you how to load the JSON.
  2. Next, you appear to want to build a new JavaScript object that has only a small subset of the data in the much larger response. That's pretty much just pulling out the bits by traversing the paths in the returned JSON. In this case though, there's a lot of data, and there's a lot of repetition. If you're looking to grab a specific piece of that data, you can either write some code to loop through elements in one of the arrays that contains the data you want (maybe the metadata.integrated_gnss_stations.features array), or using something like JSONPath (http://jsonpath.com/) to easily traverse into it.

If you use JSONPath, you could use a path like

metadata.integrated_gnss_stations.features..[?(@.rcv=='BUCU00ROU0_EUREF')]

… to get an array of all 5 satellites for the items where rcv == "BUCU00ROU0_EUREF". You can then take that return and project it into whatever other form you'd like.

Rent Charter Buses Company
READ ALSO
Find Postal Code | Zipcode using Google map geocoding reverse

Find Postal Code | Zipcode using Google map geocoding reverse

Find Postal Code | Zipcode using Google map geocoding reverse

146
VueJs - Retrieve objects from array into new object array

VueJs - Retrieve objects from array into new object array

Can anyone please help me find a way to return objects from an object array to concat all of them into a new object array with object names instead of keys

179
PHP Warning: Illegal string offset &#39;all&#39;

PHP Warning: Illegal string offset 'all'

I'm working on a PHP webpage, and I get an error on my front-end saying; Warning: Illegal string offset 'all' on line 93

182
Permanently redirect all .php links using htaccess

Permanently redirect all .php links using htaccess

I'm currently using this URL structure on my webpage: examplecom/folder/file1

171