<div dir="ltr"><div>I have a JSON endpoint that I want to load into a QGIS project as a flat table (no geometry). There are lat/ling coordinates in JSON (see below), but those coords are not important for my purpose since I want to eventually join the table with a spatial layer using a common ID. I can load the data into the console with:</div><div><br></div><div>import urllib.request, json, csv<br>with urllib.request.urlopen("<a href="https://my_json_endpoint">https://my_json_endpoint</a>") as url:<br> data = json.loads(url.read().decode())<br> print(data)<br></div><div><br></div><div>And I can load the table into QGIS as a GeoJSON with: </div><div><br></div><div>import urllib.request, json<br>uri = '<a href="https://my_json_endpoint">https://my_json_endpoint</a>'<br>iface.addVectorLayer(uri, 'Asset Data', 'ogr')<br></div><div><br></div>but the table loads without attribute data and no rows. <div><br></div><div>The JSON file looks like this (but with 20+ rows of data)</div><div><br></div><div><pre style="color:rgb(0,0,0);white-space:pre-wrap">{
"Assets": [
{
"adjusted_cost": 1940993,
"adjusted_eul": 240,
"adjusted_quantity": 1,
"amort_date": "2039-11-01",
"attributes": [],
"classifications": {
"Acc. Amort. Code": "No Acc. Amort. Code",
"Amort. Exp. Code": "No Amort. Exp. Code",
"Capital Code": "No Capital Code",
"Category": "Roads",
"Class": "Infrastructure",
"Department": "No Department",
"Function": "No Function",
"Schedule 51B Code": "No Schedule 51B Code",
"Schedule 75C Code": "No Schedule 75C Code",
"Segment": "Surface",
"Sub-Function": "No Sub-Function"
},
"condition": 100,
"condition_assessment_date": "Age-based",
"condition_ratio": 1,
"description": null,
"eul": 240,
"gis_feature_id": "roads.1",
"historical_cost": 1940993,
"id": 1,
"import_id": "PATCH-1",
"initial_quantity": 1,
"is_fully_disposed": false,
"is_fully_transferred": false,
"is_lifecycle_excluded": true,
"lat": 42.985708676898,
"lifecycle_eul": 240,
"lifecycle_eul_events": 240,
"location": null,
"lon": -81.254337208244,
"name": "Road name 1",
"profile": "Default Profile",
"replacement_cost": 0,
"replacement_date": "2039-11-01",
"risk_consequence": 5,
"risk_probability": 1,
"risk_rating": 5,
"service_date": "2019-11-12",
"unit_of_measure": "Area (m2)"
},</pre><pre style="color:rgb(0,0,0);white-space:pre-wrap"> ...</pre><pre style="color:rgb(0,0,0);white-space:pre-wrap">}</pre><pre style="color:rgb(0,0,0);white-space:pre-wrap"><br></pre><pre style="color:rgb(0,0,0);white-space:pre-wrap">I could write a script to load the data into a DB table dynamically, but it would be much better to load the data dynamically in QGIS. The ultimate objective would be to create a tool that loads the data for the user. </pre><pre style="color:rgb(0,0,0);white-space:pre-wrap">Any ideas how I can achieve this? </pre><pre style="color:rgb(0,0,0);white-space:pre-wrap">Thanks!</pre><pre style="color:rgb(0,0,0);white-space:pre-wrap">Cliff</pre></div></div>