look for json help
Posted: Wed 04 Feb 2015 6:10 pm
Hi All I am look for help with php an creating json
I have looked at http://php.net/manual/en/function.json-encode.php
By what i read If you set options like but it does not seem to wok
Here the code i started with
Im geting
im trying to get
http://n9mfk.info/newidea/test1.php
thanks Beau
I have looked at http://php.net/manual/en/function.json-encode.php
By what i read If you set options like
Code: Select all
JSON_HEX_TAGHere the code i started with
Code: Select all
<?php
//----------------------------------------------------------------------
// Generate JSON data for the Weather SteelSeries Gauges
// Author: Mark Crossley
//
// Ver 0.1 - 05/01/14 - Initial release, 0.X = a work in progress, breakages and changes on the fly likely!
//----------------------------------------------------------------------
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------
$RealtimeFilename = $_SERVER['DOCUMENT_ROOT'].'/cumuluswebtagsRealtime.php'; // realtime PHP variable file
$CurrentFilename = $_SERVER['DOCUMENT_ROOT'].'/cumuluswebtags.php'; // current PHP variable file
// set up the response headers
header('Cache-Control: private');
header('Cache-Control: no-cache, must-revalidate');
header('Content-type: text/json');
$response = decodeCumulus($CurrentFilename, $RealtimeFilename);
function decodeCumulus($currFile, $RealFile) {
global $response;
error_reporting(E_ALL);
try {
// incorporate all the Cumulus variables
include($currFile);
include($RealFile);
return array(
'data' => '[[' ,
'High Temperature' => $tempTH.'nbsp;°'.$tempunitnodeg,
);
} catch (Exception $e) {
return $e->getMessage() . ' line:' . $e->getLine();
}
}
// JSON encode the response
echo json_encode($response, JSON_HEX_TAG), "\n";
// all done!
?>
Code: Select all
{"data":"[[","High Temperature":"35.0nbsp;°F"} Code: Select all
{"data":[["High Temperature","35.0 °F","12:27 AM","40.6 °F","12:57 PM"],thanks Beau