Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions simpleAPI/simpleapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,14 @@ public function handleRequest()
}

// Einzelner Parameter: Raw-Output verwenden
echo $this->formatRawOutput($result);
echo $this->formatRawOutput($result, $paramName);
} else {
echo json_encode($result);
// Für get_lastlivevaluesjson: JSON direkt ausgeben auch ohne raw=true
if (count($readParams) === 1 && array_keys($readParams)[0] === 'get_lastlivevaluesjson') {
echo $this->formatRawOutput($result, 'get_lastlivevaluesjson');
} else {
echo json_encode($result);
}
}
return;
}
Expand Down Expand Up @@ -481,12 +486,17 @@ private function getSuccessMessage($param, $value, $chargepointId)
/**
* Raw-Ausgabe formatieren
*/
private function formatRawOutput($data)
private function formatRawOutput($data, $paramName = null)
{
if (is_array($data)) {
$firstKey = array_keys($data)[0];
$firstValue = $data[$firstKey];

// Für get_lastlivevaluesjson: JSON direkt zurückgeben
if ($paramName === 'get_lastlivevaluesjson' && is_string($firstValue)) {
return $firstValue;
}

// Für JSON-Strings: direkt den String-Wert zurückgeben
if (is_string($firstValue)) {
return $firstValue;
Expand Down