Set the auth config from the JSON string provided.
This structure should match the file downloaded from
the "Download JSON" button on in the Google Developer
Console.
@param string $json the configuration json
@throws Exception
354148
public function setAuthConfig($json)
    {
        $data = json_decode($json);
        $this->setClientId($data->client_id);
        $this->setClientSecret($data->client_secret);
    }
317615
static public function setConfig($config)
        {
            if (!is_array($config)) {
                throw new Exception("Config must be an array.");
            }

            foreach ($config as $k => $v) {
                self::$_config[$k] = $v;
            }
        }
598814
public static function write($file, array $content) {
        $jsonString = json_encode($content, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);

        if ($jsonString === false) {
            throw new Exception('Unable to convert array to JSON string', ExitApp::RUNTIME_ERROR);
        }

        $status = file_put_contents(
            $file,
            $jsonString . PHP_EOL
        );

        if ($status === false) {
            throw new Exception(sprintf(
                'Unable to write JSON-formatted content to file %s',
                $file
            ), ExitApp::RUNTIME_ERROR);
        }
    }
1321867
public function setJsonContent($content)
    {
        $context = $this->_context;

        $this->setHeader('Content-Type', 'application/json; charset=utf-8');

        if (is_array($content)) {
            if (!isset($content['code'])) {
                $content = ['code' => 0, 'message' => '', 'data' => $content];
            }
        } elseif ($content instanceof \JsonSerializable) {
            $content = ['code' => 0, 'message' => '', 'data' => $content];
        } elseif (is_string($content)) {
            null;
        } elseif (is_int($content)) {
            $content = ['code' => $content, 'message' => ''];
        } elseif ($content === null) {
            $content = ['code' => 0, 'message' => '', 'data' => null];
        } elseif ($content instanceof ValidatorException) {
            $content = ['code' => -2, 'message' => $content->getMessage()];
        } elseif ($content instanceof \Exception) {
            if ($content instanceof \ManaPHP\Exception) {
                $this->setStatus($content->getStatusCode());
                $content = $content->getJson();
            } else {
                $this->setStatus(500);
                $content = ['code' => 500, 'message' => 'Server Internal Error'];
            }
        }

        $context->content = $this->_jsonEncode($content);

        return $this;
    }
618781
public function setJson($json)
    {
        global $CFG, $PDOX;

        $q = $PDOX->queryDie("UPDATE {$CFG->dbprefix}{$this->TABLE_NAME}
                SET json = :SET WHERE $this->PRIMARY_KEY = :PK",
            array(":SET" => $json, ":PK" => $this->id)
        );
    }
982490
protected static function _parse_json($json) {
    $rval = json_decode($json);
    $error = json_last_error();
    if($error === JSON_ERROR_NONE && $rval === null) {
      $error = JSON_ERROR_SYNTAX;
    }
    switch($error) {
    case JSON_ERROR_NONE:
      break;
    case JSON_ERROR_DEPTH:
      throw new JsonLdException(
        'Could not parse JSON; the maximum stack depth has been exceeded.',
        'jsonld.ParseError');
    case JSON_ERROR_STATE_MISMATCH:
      throw new JsonLdException(
        'Could not parse JSON; invalid or malformed JSON.',
        'jsonld.ParseError');
    case JSON_ERROR_CTRL_CHAR:
    case JSON_ERROR_SYNTAX:
      throw new JsonLdException(
        'Could not parse JSON; syntax error, malformed JSON.',
        'jsonld.ParseError');
    case JSON_ERROR_UTF8:
      throw new JsonLdException(
        'Could not parse JSON from URL; malformed UTF-8 characters.',
        'jsonld.ParseError');
    default:
      throw new JsonLdException(
        'Could not parse JSON from URL; unknown error.',
        'jsonld.ParseError');
    }
    return $rval;
  }
297358
public function setConfiguration(array $configuration): void
    {
        if ($this->frozen) {
            throw new Exception('The application configuration is already defined');
        }
        $this->configuration = $this->createApplicationConfiguration($configuration);
        $this->frozen = true;
    }
884973
public static function buildFromJSON($json)
	{
		$jsonObject = json_decode($json);
		
		if(!property_exists($jsonObject, 'platformGID'))
			throw new SocialRecordFormatException('SocialRecord: Property platformGID missing!');
		if(!property_exists($jsonObject, 'globalID'))
			throw new SocialRecordFormatException('SocialRecord: Property globalID missing!');
		if(!property_exists($jsonObject, 'type'))
			throw new SocialRecordFormatException('SocialRecord: Property type missing!');
		if(!property_exists($jsonObject, 'displayName'))
			throw new SocialRecordFormatException('SocialRecord: Property displayName missing!');
		if(!property_exists($jsonObject, 'profileLocation'))
			throw new SocialRecordFormatException('SocialRecord: Property profileLocation missing!');
		if(!property_exists($jsonObject, 'personalPublicKey'))
			throw new SocialRecordFormatException('SocialRecord: Property personalPublicKey missing!');
		if(!property_exists($jsonObject, 'accountPublicKey'))
			throw new SocialRecordFormatException('SocialRecord: Property accountPublicKey missing!');
		if(!property_exists($jsonObject, 'salt'))
			throw new SocialRecordFormatException('SocialRecord: Property salt missing!');
		if(!property_exists($jsonObject, 'datetime'))
			throw new SocialRecordFormatException('SocialRecord: Property datetime missing!');
		if(!property_exists($jsonObject, 'active'))
			throw new SocialRecordFormatException('SocialRecord: Property active missing!');
		if(!property_exists($jsonObject, 'keyRevocationList'))
			throw new SocialRecordFormatException('SocialRecord: Property keyRevocationList missing!');
		
		$krl = array();
		
		foreach($jsonObject->keyRevocationList as $krc)
		{
			$krl[] = KeyRevocationCertificateBuilder::buildFromJSON($krc);
		}
		
		return (new SocialRecordBuilder())
				->type($jsonObject->type)
				->globalID($jsonObject->globalID)
				->platformGID($jsonObject->platformGID)
				->displayName($jsonObject->displayName)
				->profileLocation($jsonObject->profileLocation)
				->personalPublicKey(PublicKey::formatPEM($jsonObject->personalPublicKey))
				->accountPublicKey(PublicKey::formatPEM($jsonObject->accountPublicKey))
				->salt($jsonObject->salt)
				->datetime($jsonObject->datetime)
				->active($jsonObject->active)
				->keyRevocationList($krl)
				->build();
	}
436288
public static function fromJson($json, $localeGroup, array $languages = [])
    {
        if (empty($json) || ($capsule = json_decode($json, true)) === null) {
            throw new Exception("The provided string is not a valid json.");
        }

        if (is_array($capsule) && !Helpers::isAssociative($capsule)) {
            // At this point we know the resource file is` using old convention
            // Set the fields
            $fields = FieldTransformer::fromArray($capsule, $localeGroup, $languages, true);

            return new Resource($fields);
        }

        return self::fromArray($capsule, $localeGroup, $languages);
    }
552850
public void readJson(ConfigurationBuilderInfo builderInfo, String json) {
      readJson(builderInfo, "", Json.read(json));
   }
1319037
private static function _fromJson(&$json)
    {
        $fields = json_decode($json);

        if (is_null($fields)) {
            throw new UnexpectedResponseException(
                json_last_error_msg(),
                $json
            );
        }

        return $fields;
    }
264133
public function setFromStorage($json)
    {
        list($cache, $complete) = json_decode($json, true);

        if (json_last_error() === JSON_ERROR_NONE && is_array($cache) && is_array($complete)) {
            $this->cache = $cache;
            $this->complete = $complete;
        }
    }
220206
public static function set_Json( $json, $inputValidate )
    {
        if( $json instanceof Json ) {
            return $json;
        } elseif( null === $json ) {
            return null;
        } elseif ( !is_string($json) ) {
            return Json::makeFromObject( $json );
        }

        return new Json( $json, $inputValidate );
    }
1183136
public function set(string $key, string $value): bool
    {
        if (!$this->users_id) {
            throw new Exception('No users is set to save config');
        }

        $config = new self();
        $config->users_id = $this->users_id;
        $config->name = $key;
        $config->value = $value;
        if (!$config->save()) {
            throw new Exception(current($config->getMessages()));
        }

        return true;
    }
743808
private function setJsonData(?string $json): self
    {
        $this->updatePropertyValue(
            JsonDataFieldInterface::PROP_JSON_DATA,
            $json
        );

        return $this;
    }
288729
private void setConfig(JsonSimpleConfig config) throws IOException {
        // Get the basics
        user_object = new InternalUser();
        file_path = config.getString(null, "authentication", "internal",
                "path");
        loadUsers();
    }
818366
private static function saveFile($file, $json)
    {
        if (@file_put_contents($file, $json) === false) {
            $message = 'Could not create file in';
            throw new JsonException($message . ' ' . $file);
        }
    }