mirror of
https://github.com/peklaiho/madlisp.git
synced 2024-11-22 21:35:03 +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)
|
private function getJsonData($a)
|
||||||
{
|
{
|
||||||
if ($a instanceof Func) {
|
if ($a instanceof Collection) {
|
||||||
throw new MadLispException("unable to encode function as json");
|
|
||||||
} elseif ($a instanceof Collection) {
|
|
||||||
return array_map([$this, 'getJsonData'], $a->getData());
|
return array_map([$this, 'getJsonData'], $a->getData());
|
||||||
} elseif ($a instanceof Symbol) {
|
} elseif (is_object($a) || is_resource($a)) {
|
||||||
// Does this make sense, as we cannot reverse this operation?
|
throw new MadLispException("invalid type for json");
|
||||||
return $a->getName();
|
|
||||||
} else {
|
} else {
|
||||||
return $a;
|
return $a;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user