Skip to content

Commit

Permalink
Allow the passing-in of already decoded json objected
Browse files Browse the repository at this point in the history
  • Loading branch information
phayes committed Apr 13, 2011
1 parent cb2c140 commit 70f2593
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/adapters/GeoJSON.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@ class GeoJSON extends GeoAdapter
* Deserializes a geojson string into an object
*
*
* @param string $string The GeoJSON string
* @param mixed $input The GeoJSON string or object
*
* @return object The PHP equivalent object
*/
public function read($string)
public function read($input)
{
if (!($object = json_decode($string)))
{
if (is_string($input)) {
$input = json_decode($input);
}
if (!is_object($input)) {
throw new Exception('Invalid JSON');
}
return self::toInstance($object);
return self::toInstance($input);
}

/**
Expand Down

0 comments on commit 70f2593

Please sign in to comment.