mirror of
https://github.com/peklaiho/madlisp.git
synced 2024-11-22 13:24:46 +00:00
handle invalid types in json
This commit is contained in:
parent
838313fa9c
commit
3b58f280f7
@ -25,13 +25,10 @@ class Json implements ILib
|
||||
|
||||
private function getJsonData($a)
|
||||
{
|
||||
if ($a instanceof Func) {
|
||||
throw new MadLispException("unable to encode function as json");
|
||||
} elseif ($a instanceof Collection) {
|
||||
if ($a instanceof Collection) {
|
||||
return array_map([$this, 'getJsonData'], $a->getData());
|
||||
} elseif ($a instanceof Symbol) {
|
||||
// Does this make sense, as we cannot reverse this operation?
|
||||
return $a->getName();
|
||||
} elseif (is_object($a) || is_resource($a)) {
|
||||
throw new MadLispException("invalid type for json");
|
||||
} else {
|
||||
return $a;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user