thommy1972de
Grünschnabel
Ich lese mit folgenden Code eine lokale Json Datei aus:
Nun erhalte ich allerdings:
Wie kann ich das Unterteilen, dass ich auf die einzelnen Daten zugreifen kann ?
Die Struktur die ich benötige sieht wie folgt aus:
Code:
try (java.util.Scanner s = new java.util.Scanner(new java.net.URL("http://127.0.0.1:25555/api/ets2/telemetry").openStream())) {
System.out.println(s.useDelimiter("\\A").next());
}
Code:
{"game":{"connected":false,"gameName":null,"paused":false,"time":"0001-01-01T00:00:00Z","timeScale":0.0,"nextRestStopTime":"0001-01-01T00:00:00Z","version":"0.0","telemetryPluginVersion":"0"},"truck":{"id":"","make":"","model":"","speed":0.0,"cruiseControlSpeed":0.0,"cruiseControlOn":false,"odometer":0.0,"gear":0,"displayedGear":0,"forwardGears":0,"reverseGears":0,"shifterType":"","engineRpm":0.0,"engineRpmMax":0.0,"fuel":0.0,"fuelCapacity":0.0,"fuelAverageConsumption":0.0,"fuelWarningFactor":0.0,"fuelWarningOn":false,"wearEngine":0.0,"wearTransmission":0.0,"wearCabin":0.0,"wearChassis":0.0,"wearWheels":0.0,"userSteer":0.0,"userThrottle":0.0,"userBrake":0.0,"userClutch":0.0,"gameSteer":0.0,"gameThrottle":0.0,"gameBrake":0.0,"gameClutch":0.0,"shifterSlot":0,"engineOn":false,"electricOn":false,"wipersOn":false,"retarderBrake":0,"retarderStepCount":0,"parkBrakeOn":false,"motorBrakeOn":false,"brakeTemperature":0.0,"adblue":0.0,"adblueCapacity":0.0,"adblueAverageConsumption":0.0,"adblueWarningOn":false,"airPressure":0.0,"airPressureWarningOn":false,"airPressureWarningValue":0.0,"airPressureEmergencyOn":false,"airPressureEmergencyValue":0.0,"oilTemperature":0.0,"oilPressure":0.0,"oilPressureWarningOn":false,"oilPressureWarningValue":0.0,"waterTemperature":0.0,"waterTemperatureWarningOn":false,"waterTemperatureWarningValue":0.0,"batteryVoltage":0.0,"batteryVoltageWarningOn":false,"batteryVoltageWarningValue":0.0,"lightsDashboardValue":0.0,"lightsDashboardOn":false,"blinkerLeftActive":false,"blinkerRightActive":false,"blinkerLeftOn":false,"blinkerRightOn":false,"lightsParkingOn":false,"lightsBeamLowOn":false,"lightsBeamHighOn":false,"lightsAuxFrontOn":false,"lightsAuxRoofOn":false,"lightsBeaconOn":false,"lightsBrakeOn":false,"lightsReverseOn":false,"placement":{"x":0.0,"y":0.0,"z":0.0,"heading":0.0,"pitch":0.0,"roll":0.0},"acceleration":{"x":0.0,"y":0.0,"z":0.0},"head":{"x":0.0,"y":0.0,"z":0.0},"cabin":{"x":0.0,"y":0.0,"z":0.0},"hook":{"x":0.0,"y":0.0,"z":0.0}},"trailer":{"attached":false,"id":"","name":"","mass":0.0,"wear":0.0,"placement":{"x":0.0,"y":0.0,"z":0.0,"heading":0.0,"pitch":0.0,"roll":0.0}},"job":{"income":0,"deadlineTime":"0001-01-01T00:00:00Z","remainingTime":"0001-01-01T00:00:00Z","sourceCity":"","sourceCompany":"","destinationCity":"","destinationCompany":""},"navigation":{"estimatedTime":"0001-01-01T00:00:00Z","estimatedDistance":0,"speedLimit":0}}
Wie kann ich das Unterteilen, dass ich auf die einzelnen Daten zugreifen kann ?
Die Struktur die ich benötige sieht wie folgt aus: