aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2013-05-20 22:41:46 -0400
committerTeddy Wing2013-05-20 22:41:46 -0400
commit02a5e52d982404f03a0e484b14a1565fd2feb2ce (patch)
tree70dceeddb76da5badc926469352bccd7c528eb2f
parent06ffae720056f446af6a5f4803b58bf9a859d73a (diff)
downloadBoston-Food-Truck-Schedule-API-02a5e52d982404f03a0e484b14a1565fd2feb2ce.tar.bz2
Change the way JSON encoding is handled
Don't JSON-encode output from the BostonFoodTrucks class and instead return as a regular PHP object. Do the JSON-encoding directly in the HTTP API.
-rw-r--r--boston_food_trucks.php2
-rw-r--r--http.php2
-rw-r--r--index.php10
3 files changed, 7 insertions, 7 deletions
diff --git a/boston_food_trucks.php b/boston_food_trucks.php
index 37bb4f9..b873255 100644
--- a/boston_food_trucks.php
+++ b/boston_food_trucks.php
@@ -99,7 +99,7 @@ class BostonFoodTrucks {
}
- return json_encode($this->food_truck_output);
+ return $this->food_truck_output;
}
diff --git a/http.php b/http.php
index 7c8abe6..ddea68f 100644
--- a/http.php
+++ b/http.php
@@ -52,4 +52,4 @@ $Filters->get_filters($R->parameters);
// Output JSON from food truck API
$BostonFoodTrucks = new BostonFoodTrucks;
-echo $BostonFoodTrucks->schedule($Filters->filters);
+echo json_encode($BostonFoodTrucks->schedule($Filters->filters));
diff --git a/index.php b/index.php
index afbfb8c..e3e7f94 100644
--- a/index.php
+++ b/index.php
@@ -5,11 +5,11 @@ error_reporting(0);
require_once('boston_food_trucks.php');
$BostonFoodTrucks = new BostonFoodTrucks;
-$schedule = json_decode($BostonFoodTrucks->schedule(array(
+$schedule = $BostonFoodTrucks->schedule(array(
'days_of_week' => array(date('l')),
'times_of_day' => array('Lunch'),
'locations' => $BostonFoodTrucks->locations_downtown
-)));
+));
?>
<!doctype html>
@@ -103,14 +103,14 @@ $schedule = json_decode($BostonFoodTrucks->schedule(array(
<div role="main">
<table id="trucks">
- <?php foreach ($schedule->food_trucks as $truck): ?>
+ <?php foreach ($schedule['food_trucks'] as $truck): ?>
<tr>
<td class="company">
- <a href="<?= $truck->company_url ?>"><?= $truck->company ?></a>
+ <a href="<?= $truck['company_url'] ?>"><?= $truck['company'] ?></a>
</td>
<td class="location">
- <?= $truck->location ?>
+ <?= $truck['location'] ?>
</td>
</tr>
<?php endforeach; ?>