Generates the tsConfig typoscript and registers
the icons for the content elements

@param array $json
@return string
425961
public function generateTsConfig($json)
    {
        // generate page TSconfig
        $content = "";
        $iconRegistry = GeneralUtility::makeInstance("TYPO3\CMS\Core\Imaging\IconRegistry");

        // make content-Elements
        if ($json["tt_content"]["elements"]) {
            foreach ($json["tt_content"]["elements"] as $element) {
                // Register icons for contentelements
                $iconIdentifier = 'mask-ce-' . $element["key"];
                $iconRegistry->registerIcon(
                    $iconIdentifier, "MASK\Mask\Imaging\IconProvider\ContentElementIconProvider", array(
                        'contentElementKey' => $element["key"]
                    )
                );

                if (!$element["hidden"]) {

                    // add the content element wizard for each content element
                    $wizard = [
                        'header' => 'LLL:EXT:mask/Resources/Private/Language/locallang_mask.xlf:new_content_element_tab',
                        'elements.mask_' . $element["key"] => [
                            'iconIdentifier' => $iconIdentifier,
                            'title' => $element["label"],
                            'description' => $element["description"],
                            'tt_content_defValues' => [
                                'CType' => 'mask_' . $element["key"]
                            ]
                        ],

                    ];
                    $content .= "mod.wizards.newContentElement.wizardItems.mask {\n";
                    $content .= $this->convertArrayToTypoScript($wizard, '', 1);
                    $content .= "\tshow := addToList(mask_" . $element["key"] . ");\n";
                    $content .= "}\n";

                    // and switch the labels depending on which content element is selected
                    $content .= "\n[userFunc = user_mask_contentType(CType|mask_" . $element["key"] . ")]\n";
                    if ($element["columns"]) {
                        foreach ($element["columns"] as $index => $column) {
                            $content .= " TCEFORM.tt_content." . $column . ".label = " . $element["labels"][$index] . "\n";
                        }
                    }
                    $content .= "[end]\n\n";
                }
            }
        }
        return $content;
    }
953623
public static function create(array $json)
    {
        $unregisterDeviceResponse = new UnregisterDeviceResponse();
        $unregisterDeviceResponse->setStatusCode($json['status_code']);
        $unregisterDeviceResponse->setStatusMessage($json['status_message']);

        return $unregisterDeviceResponse;
    }
431463
public function minify($json){
			$tokenizer = "/\"|(\/\*)|(\*\/)|(\/\/)|\n|\r/";
			$in_string = false;
			$in_multiline_comment = false;
			$in_singleline_comment = false;
			$tmp; $tmp2; $new_str = array(); $ns = 0; $from = 0; $lc; $rc; $lastIndex = 0;
			while (preg_match($tokenizer,$json,$tmp,PREG_OFFSET_CAPTURE,$lastIndex)){
				$tmp = $tmp[0];
				$lastIndex = $tmp[1] + strlen($tmp[0]);
				$lc = substr($json,0,$lastIndex - strlen($tmp[0]));
				$rc = substr($json,$lastIndex);
				if (!$in_multiline_comment && !$in_singleline_comment){
					$tmp2 = substr($lc,$from);
					if (!$in_string){
						$tmp2 = preg_replace("/(\n|\r|\s)*/","",$tmp2);
					}
					$new_str[] = $tmp2;
				}
				$from = $lastIndex;
				if ($tmp[0] == "\"" && !$in_multiline_comment && !$in_singleline_comment){
					preg_match("/(\\\\)*$/",$lc,$tmp2);
					if (!$in_string || !$tmp2 || (strlen($tmp2[0]) % 2) == 0){ // start of string with ", or unescaped " character found to end string
						$in_string = !$in_string;
					}
					$from--; // include " character in next catch
					$rc = substr($json,$from);
				} else if ($tmp[0] == "/*" && !$in_string && !$in_multiline_comment && !$in_singleline_comment){
					$in_multiline_comment = true;
				} else if ($tmp[0] == "*/" && !$in_string && $in_multiline_comment && !$in_singleline_comment){
					$in_multiline_comment = false;
				} else if ($tmp[0] == "//" && !$in_string && !$in_multiline_comment && !$in_singleline_comment){
					$in_singleline_comment = true;
				} else if (($tmp[0] == "\n" || $tmp[0] == "\r") && !$in_string && !$in_multiline_comment && $in_singleline_comment){
					$in_singleline_comment = false;
				} else if (!$in_multiline_comment && !$in_singleline_comment && !(preg_match("/\n|\r|\s/",$tmp[0]))){
					$new_str[] = $tmp[0];
				}
			}
			$new_str[] = $rc;
			return implode("",$new_str);
		}
739535
private function prettyPrint($json) {
        $tokens = preg_split('|([\{\}\]\[,])|', $json, -1, PREG_SPLIT_DELIM_CAPTURE);
        $result = '';
        $indent = 0;
        $ind = '  ';
        $lineBreak = "\n";

        $inLiteral = false;
        foreach ($tokens as $token) {
            if ($token == '') {
                continue;
            }
            $prefix = str_repeat($ind, $indent);
            if (!$inLiteral && ($token == '{' || $token == '[')) {
                $indent++;
                if (($result != '') && ($result[(strlen($result) - 1)] == $lineBreak)) {
                    $result .= $prefix;
                }
                $result .= $token . $lineBreak;
            } elseif (!$inLiteral && ($token == '}' || $token == ']')) {
                $indent--;
                $prefix = str_repeat($ind, $indent);
                $result .= $lineBreak . $prefix . $token;
            } elseif (!$inLiteral && $token == ',') {
                $result .= $token . $lineBreak;
            } else {
                $result .= ($inLiteral ? '' : $prefix) . $token;
                // Count # of unescaped double-quotes in token, subtract # of
                // escaped double-quotes and if the result is odd then we are
                // inside a string literal
                if ((substr_count($token, "\"") - substr_count($token, "\\\"")) % 2 != 0) {
                    $inLiteral = !$inLiteral;
                }
            }
        }
        return $result;
    }
25194
protected function _addQueryLogsNode($json)
    {
        $listener = $this->_getApiQueryLogListenerObject();
        $logs = $listener->getQueryLogs();

        if (empty($logs)) {
            return $json;
        }

        $result = json_decode($json, true);
        $result['query'] = $logs;

        return json_encode($result, JSON_PRETTY_PRINT);
    }
42748
public function write($json)
    {
        if (!empty($this->extSettings['json'])) {
            $file = MaskUtility::getFileAbsFileName($this->extSettings['json']);
            GeneralUtility::writeFile(
                $file,
                json_encode($json, JSON_PRETTY_PRINT)
            );
        }
        self::$json = $json;
    }
224122
protected function compressInlineJsonCode($json)
    {
        if (!($json = (string) $json)) {
            return $json; // Nothing to do.
        }
        if (($compressed_json = \WebSharks\JsMinifier\Core::compress($json))) {
            return '/*<![CDATA[*/'.$compressed_json.'/*]]>*/';
        }
        return $json;
    }
333999
public function json() : string
    {
        return json_encode([
            'title' => $this->title,
            'body' => $this->body,
            'url' => $this->url,
            'icon' => $this->icon,
        ]);
    }
314414
public function generate($json): bool
    {
        $this->json = $json;

        $view      = $this->getView();
        $variables = $this->getVariables();

        $path = $this->getPath();
        if (file_exists($path)) {
            unlink($path);
        }
        $this->fileService->render($view, $path, $variables);

        return true;
    }
30155
public function buildBodyJson($contents)
    {
        $this->contextDataType   = self::CONTENT_TYPE_JSON;
        $this->contextDataExists = (bool) (strlen($contents) > 0);
        $this->contextDataValue  = json_decode($contents, false);

        if (json_last_error() !== JSON_ERROR_NONE) {
            $this->contextDataEmpty = true;
            $this->contextDataValue = null;
            if (function_exists('json_last_error_msg')) {
                $this->contextDecodeError = array(array('code' => json_last_error(), 'message' => json_last_error_msg()));
            }
            else {
                $this->contextDecodeError = array(array('code' => json_last_error(), 'message' => null));
            }
        }
        else {
            $this->checkDataIsEmpty();
        }
    }
1185232
public function parseJson($json)
    {
        $this->mentionName = $json['mention_name'];
        $this->id = $json['id'];
        $this->name = $json['name'];
        if (isset($json['links'])) {
            $this->links = $json['links'];
        }
        if(isset($json['xmpp_jid'])) {
            $this->xmppJid = $json['xmpp_jid'];
            $this->deleted = $json['is_deleted'];
            $this->lastActive = $json['last_active'];
            $this->title = $json['title'];
            $this->created = new \Datetime($json['created']);
            $this->groupAdmin = $json['is_group_admin'];
            $this->timezone = $json['timezone'];
            $this->guest = $json['is_guest'];
            $this->email = $json['email'];
            $this->photoUrl = $json['photo_url'];
        }
    }
1261847
public static function jsonToArray($json)
    {
        if (empty($json)) {
            return null;
        }

        $array = json_decode($json, true);

        switch (json_last_error()) {
            case JSON_ERROR_NONE:
                $message = null;
                break;

            case JSON_ERROR_STATE_MISMATCH:
                $message = 'Invalid or malformed JSON';
                break;

            case JSON_ERROR_UTF8:
                $message = 'Malformed UTF-8 characters, possibly incorrectly encoded';
                break;

            case JSON_ERROR_DEPTH:
                $message = 'The maximum stack depth has been exceeded';
                break;

            case JSON_ERROR_CTRL_CHAR:
                $message = 'Control character error, possibly incorrectly encoded';
                break;

            case JSON_ERROR_SYNTAX:
                $message = 'Syntax error, malformed JSON';
                break;

            default:
                $message = 'Unknown error';
                break;
        }

        if (!empty($message)) {
            throw new \InvalidArgumentException('JSON Error: ' . $message);
        }

        return $array;
    }
203418
public static function convertImageJson($json): string
    {
        if (empty($json))
            return "";
        elseif (is_array($json) && !empty($json[0]['url']))
            return HOME . str_replace('\\', '/', $json[0]['url']);
        elseif (Check::isJson($json) && preg_match('/url/i', $json))
            return HOME . str_replace('\\', '/', json_decode($json, true)[0]['url']);

        return "";
    }
143836
private function importExtendedConfiguration($json)
    {
        $configuration = json_decode($json, true);
        if (isset($configuration['$extend'])) {
            $extendConfigurationFile = $configuration['$extend'];
            $extendConfigurationFileScheme = parse_url($extendConfigurationFile, PHP_URL_SCHEME);
            if (substr($extendConfigurationFile, 0, 1) === '/' || isset($extendConfigurationFileScheme) === false) {
                $extendConfigurationFile = sprintf('%s/%s', dirname($this->configurationFile), $configuration['$extend']);
            }
            unset($configuration['$extend']);

            $parentConfiguration = new static($extendConfigurationFile, $this->configurationSchema);
            $parentConfiguration->load();

            $configuration = array_merge_recursive($parentConfiguration->configuration, $configuration);

            $json = json_encode($configuration);
        }

        return $json;
    }
1178951
protected function jsonDecode($json)
    {
        $content = json_decode((string) $json, true);
        $this->handleJsonError(json_last_error());
        
        return $content;
    }
288522
private function simple_json_parser($json){
        $json = str_replace("{","",str_replace("}","", $json));
        $jsonValue = explode(",", $json);
        $arr = array();
        foreach($jsonValue as $v){
            $jValue = explode(":", $v);
            $arr[str_replace('"',"", $jValue[0])] = (str_replace('"', "", $jValue[1]));
        }
        return $arr;
    }
1369056
protected function _getInputIcon(array $properties) : string
    {
        $config = (new ModuleConfig(ConfigType::MODULE(), $properties['controller']))->parseToArray();

        if (! isset($config['table'])) {
            return Configure::read('CsvMigrations.default_icon');
        }

        if (! isset($config['table']['icon'])) {
            return Configure::read('CsvMigrations.default_icon');
        }

        return $config['table']['icon'];
    }