You can get all capabilities thought method driver.getCapabilities()
As all capabilities are a Map (key and value) get the capabilities asMap()
The desired capabilities are a map inside the capabilities map, so you need to get that (desired is the key) and put in another Map
After that get the capability you want
To show the platform version see this code snippet in Java:
Capabilities cap = driver.getCapabilities();
Map<String, ?> desired = (Map<String, ?>) cap.getCapability("desired");
System.out.println(desired.get("platformVersion"));