Skip to content

Instantly share code, notes, and snippets.

@rickard2
Created September 10, 2012 12:35
Show Gist options
  • Save rickard2/3690671 to your computer and use it in GitHub Desktop.
Save rickard2/3690671 to your computer and use it in GitHub Desktop.
<?php
class JsonDecoder implements DecoderInterface {
public function decode( $data )
{
$decoded = @json_decode( $data, true );
$decoded = $this->removeBooleans( $decoded );
return $decoded;
}
private function removeBooleans( $array )
{
foreach ( $array as $key => $item ) {
if ( is_array( $item ) ) {
$array[ $key ] = $this->removeBooleans( $item );
} else if ( $item === false ) {
unset( $array[ $key ] );
}
}
return $array;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment