The object you get from a TopoJSON file looks something like this:
{
"type": "Topology",
"objects": {
"countries": {
"type": "GeometryCollection",
"geometries": [
{
"type": "MultiPolygon",
"arcs": [],
"id": "242",
"properties": {
"name": "Fiji"
}
},
{
"type": "Polygon",
"arcs": [],
"id": "834",
"properties": {
"name": "Tanzania"
}
},
...etc
Using topojson-client, you can extract the geometries with a line something like this:
geography = feature(worlddata, worlddata.objects.countries).features
The problem is that this case only works for the file found at:
https://cdn.jsdelivr.net/npm/world-atlas@2/countries-110m.json
If you load a different file, the object structure may have a different property name where “countries” is.
To make this dynamic and able to load different TopoJSON files, is there a way to get the property, who in turn has a property “type”: “GeometryCollection”?
Will