Helper that creates a group response object from the given
fields.

@param string $json   original JSON message
@param object $fields the fields as generated by `json_decode`

@return Api\GroupResult the created group response
558949
private static function _groupResponseFromFields(&$json, &$fields)
    {
        $result = new Api\GroupResult();
        $result->setChildGroups($fields->child_groups);
        $result->setGroupId($fields->id);
        $result->setSize($fields->size);
        $result->setCreatedAt(
            Deserialize::_dateTime($json, $fields->created_at)
        );
        $result->setModifiedAt(
            Deserialize::_dateTime($json, $fields->modified_at)
        );

        if (isset($fields->name)) {
            $result->setName($fields->name);
        }

        if (isset($fields->auto_update)) {
            $result->setAutoUpdate(
                Deserialize::_autoUpdateFromFields($fields->auto_update)
            );
        }

        return $result;
    }
125671
public static function makeFromJson(JsonResponse $json)
    {
        $content = $json->getContent();

        // If the contents of the JsonResponse does not starts with /**/ (typical laravel jsonp response)
        // we assume that it is a valid json response that can be decoded, or we just use the raw jsonp
        // contents for building the response
        if (! starts_with($json->getContent(), '/**/')) {
            $content = json_decode($json->getContent(), true);
        }

        $new = static::create($content, $json->getStatusCode());

        $new->headers = $json->headers;

        return $new;
    }
1249048
public static function fromJson($json){
    if(is_string($json)){
      $json = json_decode($json);
    }
    
    if(!property_exists($json, 'total')){
      throw new BadResponseException('Required parameter "total" not found');
    }
    if(!property_exists($json, 'fns_site')){
      throw new BadResponseException('Required parameter "fns_site" not found');
    }
    if(!property_exists($json, 'fn_number')){
      throw new BadResponseException('Required parameter "fn_number" not found');
    }
    if(!property_exists($json, 'shift_number')){
      throw new BadResponseException('Required parameter "shift_number" not found');
    }
    if(!property_exists($json, 'receipt_datetime')){
      throw new BadResponseException('Required parameter "receipt_datetime" not found');
    }
    if(!property_exists($json, 'fiscal_receipt_number')){
      throw new BadResponseException('Required parameter "fiscal_receipt_number" not found');
    }
    if(!property_exists($json, 'fiscal_document_number')){
      throw new BadResponseException('Required parameter "fiscal_document_number" not found');
    }
    if(!property_exists($json, 'fiscal_document_attribute')){
      throw new BadResponseException('Required parameter "fiscal_document_attribute" not found');
    }
    if(!property_exists($json, 'ecr_registration_number')){
      throw new BadResponseException('Required parameter "ecr_registration_number" not found');
    }

    return new self(
      $json->total,
      $json->fns_site,
      $json->fn_number,
      $json->shift_number,
      new DateTime($json->receipt_datetime),
      $json->fiscal_receipt_number,
      $json->fiscal_document_number,
      $json->fiscal_document_attribute,
      $json->ecr_registration_number
    );
  }
27877
private function decodeJSON($json)
    {
        $query = json_decode($json);
        if (json_last_error()) {
            throw new \Exception('JSON parsing threw an error: '.json_last_error_msg());
        }
        if (!is_object($query)) {
            throw new \Exception('The query is not valid JSON');
        }

        return $query;
    }
22447
public function json($fields = array(), $recursive = true)
    {
        $list = array();
        foreach ($this->getModels() as $model) {
            $list[] = $model->json($fields, $recursive);
        }
        return $list;
    }
774626
public function create(array $fields)
    {
        $url = $this->client->url . "/rest/v1/activities/external.json";
        $response = $this->post($url, ['input' => $fields]);

        if (!$response->success) {
            throw new MarketoApiException('Error creating custom activity: ' . $response->errors[0]->message);
        }
    }
75015
public static function deserializeDocument(string $json): HalDocument
    {
        $data = json_decode($json, true);
        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new JsonException('Unable to parse HAL document JSON: '.json_last_error_msg());
        }

        return self::createDocument($data);
    }
1116693
public function get($webhookId, array $fields = array())
    {
        $params = array();
        if (!empty($fields)) {
            $params['fields'] = implode(',', $fields);
        }
        $response = $this->request('/admin/webhooks/'.$webhookId.'.json', 'GET', $params);
        return $this->createObject(Webhook::class, $response['webhook']);
    }
953623
public static function create(array $json)
    {
        $unregisterDeviceResponse = new UnregisterDeviceResponse();
        $unregisterDeviceResponse->setStatusCode($json['status_code']);
        $unregisterDeviceResponse->setStatusMessage($json['status_message']);

        return $unregisterDeviceResponse;
    }
1319037
private static function _fromJson(&$json)
    {
        $fields = json_decode($json);

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

        return $fields;
    }
665704
protected function jsonResponse($json = null)
    {
        if (!$json) {
            $json = $this->file instanceof Folder ? $this->parent->createFolderJson($this->file)
                : $this->parent->createFileJson($this->file);
        }

        $response = new SS_HTTPResponse(
            Convert::array2json($json), 200
        );

        return $response->addHeader('Content-Type', 'application/json');
    }
1264277
public static function create(array $json)
    {
        $pushStatResponse = new PushStatResponse();
        $pushStatResponse->setStatusCode($json['status_code']);
        $pushStatResponse->setStatusMessage($json['status_message']);

        return $pushStatResponse;
    }
388322
public static function fromJson($json) {
        if (!$json) {
            $json = array();
        }

        if (!is_array($json)) {
            if (is_object($json)) {
                $json = (array) $json;
            } elseif (is_string($json)) {
                $json = json_decode(trim($json) ? $json : '{}', true);
            } else {
                throw new \InvalidArgumentException("JSON must be a string, an array or an object ('" . gettype($json) . "' provided).");
            }
        }

        return new Link(
            isset($json['href'])        ? $json['href']            : null,
            isset($json['templated'])    ? $json['templated']    : null,
            isset($json['type'])        ? $json['type']            : null,
            isset($json['deprecation'])    ? $json['deprecation']    : null,
            isset($json['name'])        ? $json['name']            : null,
            isset($json['profile'])        ? $json['profile']        : null,
            isset($json['title'])        ? $json['title']        : null,
            isset($json['hreflang'])    ? $json['hreflang']        : null
        );
    }
845912
public static function RawSignedModelFromJson($json)
    {
        $body = json_decode($json, true);
        $signatures = $body['signatures'];

        $rawSignatures = [];
        foreach ($signatures as $signature) {
            $signatureSnapshot = null;
            if (array_key_exists('snapshot', $signature)) {
                $signatureSnapshot = $signature['snapshot'];
            }

            $rawSignatures[] = new RawSignature(
                $signature['signer'], base64_decode($signature['signature']), base64_decode($signatureSnapshot)
            );
        }


        return new RawSignedModel(base64_decode($body['content_snapshot']), $rawSignatures);
    }
863330
public static function fromJson($json)
    {
        $responseData = json_decode($json, true);

        if ( ! $responseData)
            return new static(false, [ResponseV3::E_INVALID_JSON]);

        return static::fromArray($responseData);
    }
1321592
private function decodeJSON($json)
    {
        $query = json_decode($json);

        if (json_last_error()) {
            throw new QBParseException('JSON parsing threw an error: '.json_last_error_msg());
        }

        if (!is_object($query)) {
            throw new QBParseException('The query is not valid JSON');
        }

        return $query;
    }
1336134
public static function moSms($json)
    {
        $fields = Deserialize::_fromJson($json);
        return Deserialize::_moSmsFromFields($json, $fields);
    }