RedditPP Mascot

RedditPP

r/swift • … • u/mitchlol

[Help] How do I decode a JSON response with dynamic keys with Combine?

I'm trying to retrieve a [list of servers](https://www.vultr.com/api/#server_server_list) from the Vultr API, but it maps the server ids to the keys like this:

{ "576965": { "SUBID": "576965", "os": "CentOS 6 x64", "ram": "4096 MB", "disk": "Virtual 60 GB", "main_ip": "123.123.123.123", "vcpu_count": "2", "location": "New Jersey", "DCID": "1", "default_password": "nreqnusibni", "date_created": "2013-12-19 14:45:41", "pending_charges": "46.67", "status": "active", "cost_per_month": "10.05", "current_bandwidth_gb": 131.512, "allowed_bandwidth_gb": "1000", "netmask_v4": "255.255.255.248", "gateway_v4": "123.123.123.1", "power_status": "running", "server_state": "ok", "VPSPLANID": "28", "v6_main_ip": "2001:DB8:1000::100", "v6_network_size": "64", "v6_network": "2001:DB8:1000::", "v6_networks": [ { "v6_network": "2001:DB8:1000::", "v6_main_ip": "2001:DB8:1000::100", "v6_network_size": "64" } ], "label": "my new server", "internal_ip": "10.99.0.10", "kvm_url": "https://my.vultr.com/subs/novnc/api.php?data=eawxFVZw2mXnhGUV", "auto_backups": "yes", "tag": "mytag", "OSID": "127", "APPID": "0", "FIREWALLGROUPID": "0" } }

All of the resources I can find show examples of decoding JSON where the keys are already known, how do I decode a response when I don't know what the keys are? Is there a way of removing the keys entirely? The id is already listed within each server object so I don't require it from the key.

— 0