IcingaObject: allow mor control over JSON structure

This commit is contained in:
Thomas Gelf 2016-02-03 00:58:13 +01:00
parent 5bafc78f1c
commit c62b008df8

View File

@ -1090,14 +1090,23 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
} }
} }
if ($skipNull) {
if (empty($props['imports'])) unset($props['imports']);
if (count((array) $props['vars']) === 0) unset($props['vars']);
if (empty($props['groups'])) unset($props['groups']);
}
ksort($props); ksort($props);
return (object) $props; return (object) $props;
} }
public function toJson($resolved = false) public function toJson(
{ $resolved = false,
return json_encode($this->toPlainObject($resolved)); $skipNull = false,
array $chosenProperties = null
) {
return json_encode($this->toPlainObject($resolved, $skipNull, $chosenProperties));
} }
public function __toString() public function __toString()