public static function FromJSON($oJson) { if (!isset($oJson->items)) { throw new Exception("Missing 'items' elements"); } $oCaseLog = new ormCaseLog(); foreach ($oJson->items as $oItem) { $oCaseLog->AddLogEntryFromJSON($oItem); } return $oCaseLog; }
/** * Helper to form a value, given JSON decoded data * The operation is the opposite to GetForJSON */ public function FromJSONToValue($json) { if (is_string($json)) { // Will be correctly handled in MakeRealValue $ret = $json; } else { if (isset($json->add_item)) { // Will be correctly handled in MakeRealValue $ret = $json->add_item; if (!isset($ret->message)) { throw new Exception("Missing mandatory entry: 'message'"); } } else { $ret = ormCaseLog::FromJSON($json); } } return $ret; }