function load_psets_json($exclude_overrides) { $datamap = psets_json_data($exclude_overrides); if (!count($datamap)) { Multiconference::fail_message("\$Opt[\"psetsConfig\"] is not set correctly."); } $json = (object) array("_defaults" => (object) array()); foreach ($datamap as $fname => $data) { if ($data === false) { Multiconference::fail_message("{$fname}: Required configuration file cannot be read."); } $x = json_decode($data); if (!$x) { Json::decode($data); // our JSON decoder provides error positions Multiconference::fail_message("{$fname}: Invalid JSON. " . Json::last_error_msg()); } else { if (!is_object($x)) { Multiconference::fail_message("{$fname}: Not a JSON object."); } } object_replace_recursive($json, $x); } return $json; }
function json_last_error_msg() { return Json::last_error_msg(); }
private static function add_json($jlist, $fixed, $landmark) { if (is_string($jlist)) { if (($jlistx = json_decode($jlist)) !== false) { $jlist = $jlistx; } else { if (json_last_error()) { Json::decode($jlist); error_log("{$landmark}: Invalid JSON. " . Json::last_error_msg()); return; } } if (is_object($jlist)) { $jlist = [$jlist]; } } foreach ($jlist as $oj) { if (is_object($oj) && isset($oj->id) && isset($oj->name)) { if (is_string($oj->id) && is_numeric($oj->id)) { $oj->id = intval($oj->id); } if (is_int($oj->id) && !isset(self::$jlist[$oj->id]) && $oj->id >= self::MINFIXEDID === $fixed && is_string($oj->name)) { if (!isset($oj->abbr) || $oj->abbr == "") { $oj->abbr = self::abbreviate($oj->name, $oj->id); } self::$jlist[$oj->id] = $oj; continue; } } error_log("{$landmark}: bad option " . json_encode($oj)); } }
private static function read($info, $text, $fname) { $j = json_decode($text, true); if (is_array($j)) { $info = array_replace_recursive($info, $j); } else { if (json_last_error() !== JSON_ERROR_NONE) { Json::decode($text); // our JSON decoder provides error positions trigger_error("{$fname}: Invalid JSON, " . Json::last_error_msg()); } } return $info; }