Build json encode options (pretty print in development mode)
@param bool $prettyPrintIfDev
@return int
974858
protected static function getOptions(bool $prettyPrintIfDev): int
    {
        $pp = $prettyPrintIfDev && Container::getApplication()->isDevelopment();
        return JSON_UNESCAPED_UNICODE | ($pp ? JSON_PRETTY_PRINT : 0);
    }
1334953
public function render(Hal $resource, $pretty, $encode = true)
    {
        $doc = new \SimpleXMLElement('<resource></resource>');
        if (!is_null($resource->getUri())) {
            $doc->addAttribute('href', $resource->getUri());
        }
        $this->linksForXml($doc, $resource->getLinks());

        $this->arrayToXml($resource->getData(), $doc);

        foreach ($resource->getResources() as $rel => $resources) {
            $this->resourcesForXml($doc, $rel, $resources);
        }

        $dom = dom_import_simplexml($doc);
        if ($pretty) {
            $dom->ownerDocument->preserveWhiteSpace = false;
            $dom->ownerDocument->formatOutput = true;
        }

        return $dom->ownerDocument->saveXML();
    }
257974
public static function toJson(array $array, bool $prettyPrint = true, bool $unescapedSlashes = true): string
    {
        $options = 0;
        if ($unescapedSlashes) {
            $options += JSON_UNESCAPED_SLASHES;
        }
        if ($prettyPrint) {
            $options += JSON_PRETTY_PRINT;
        }
        return json_encode($array, $options);
    }
1259949
public function encode($valueToEncode, bool $unescaped = false, bool $pretty = false)
    {
        $options = 0;

        if ($unescaped) {
            $options = $options | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES;
        }

        if ($pretty) {
            $options = $options | JSON_PRETTY_PRINT;
        }

        return $options > 0 ? json_encode($valueToEncode, $options) : $this->jsonHelper->jsonEncode($valueToEncode);
    }
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;
    }
918753
public function jsonEncode($data, $prettyPrint)
    {
        try {
            $data = json_encode($data, (($prettyPrint) ? JSON_PRETTY_PRINT : 15));
        } catch (\Exception $e) {
            if ('Exception' === get_class($e) && 0 === strpos($e->getMessage(), 'Failed calling ')) {
                throw $e->getPrevious() ?: $e;
            }

            throw $e;
        }

        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new \InvalidArgumentException(json_last_error_msg());
        }

        return $data;
    }
852054
public function toHTML($pretty_print = TRUE) {

    $this->out = new \DOMDocument('1.0', 'UTF-8');
    $this->out->formatOutput = $pretty_print;
    $field = $this->doc->getElementsByTagName('xlf:group')->item(0);

    foreach ($field->childNodes as $child) {
      if ($output = $this->convert($child)) {
        $this->out->appendChild($output);
      }
    }

    return html_entity_decode($this->out->saveHTML(), ENT_QUOTES, 'UTF-8');
  }
864904
function outputToStdout(prettyPrint) {
  if (prettyPrint && !_.isNumber(prettyPrint)) {
    prettyPrint = 4;
  }
  return function(err, value, callback) {
    if (err) {
      console.error(err);
    } else {
      var str = JSON.stringify(value, null, prettyPrint);
      console.log(str);
    }
    callback(err, value);
  };
}
1140721
public static function encode($data, $prettyPrint = true)
    {
        $options = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT;

        $useNative = self::$useNativePrettyPrint && defined('JSON_PRETTY_PRINT') && defined('JSON_UNESCAPED_SLASHES');
        if ($prettyPrint && $useNative) {
            $options = $options | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES;
        }

        $json = json_encode($data, $options);
        if ($prettyPrint && !$useNative) {
            $json = self::prettyPrint($json);
        }

        return $json;
    }
843615
public function toJson($data = null, $pretty = false)
	{
		if ($data === null)
		{
			$data = $this->data;
		}

		// To allow exporting ArrayAccess objects like Orm\Model instances they need to be
		// converted to an array first
		$data = (is_array($data) or is_object($data)) ? $this->toArray($data) : $data;

		// Return the result in the requested format
		if ($pretty)
		{
			return $this->prettyJson($data);
		}
		else
		{
			$result = json_encode($data, Arr::get($this->config, 'json.encode.options', JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP));
			return json_last_error() === JSON_ERROR_NONE ? $result : false;
		}
	}
424618
public String toVoJSONString(boolean pretty) {
        if (pretty) {
            return JSON.toJSONStringWithDateFormat(toVoJSONObject(), Constant.DATE_SERIALIZE_FORMAT, SerializerFeature.PrettyFormat);
        } else {
            return JSONObject.toJSONStringWithDateFormat(toVoJSONObject(), Constant.DATE_SERIALIZE_FORMAT);
        }
    }
459727
public static function putJson(string $filename, array $data, bool $prettyPrint = true): void
    {
        if (!Str::endsWith($filename, '.json')) {
            $filename .= '.json';
        }
        $options = JSON_UNESCAPED_SLASHES;
        if ($prettyPrint) {
            $options += JSON_PRETTY_PRINT;
        }
        $data = json_encode($data, $options);
        self::put($filename, $data);
    }
448547
public static function encode($value, $options = 0): string
	{
		$flags = \PHP_VERSION_ID >= 50400
			? (\JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES | ($options & self::PRETTY
					? \JSON_PRETTY_PRINT
					: 0))
			: 0;

		if (\PHP_VERSION_ID < 50500) {
			$json = Callback::invokeSafe('json_encode', [$value, $flags], static function ($message) { // needed to receive 'recursion detected' error

				throw new JsonException($message);
			});
		} else {
			$json = \json_encode($value, $flags);
		}

		$error = \json_last_error();

		if ($error) {
			$message = static::$messages[$error] ?? (\PHP_VERSION_ID >= 50500 ? \json_last_error_msg() : 'Unknown error');

			throw new JsonException($message, $error);
		}

		$json = \str_replace(["\xe2\x80\xa8", "\xe2\x80\xa9"], ['\u2028', '\u2029'], $json);

		return $json;
	}
1221796
public static function encode( $array, $beautify = false ) 
	{	
		// php53 fix
		if ( defined( 'JSON_UNESCAPED_SLASHES' ) )
		{
			$json =  json_encode( $array, JSON_UNESCAPED_SLASHES );
		}
		else 
		{
			$json =  json_encode( $array );
		}
		
		if ( $beautify ) 
		{
			return static::beautify( $json );
		}
		
		return $json;
	}
1203760
public function export($pretty=false)
    {
        $tmp = new \stdClass();
        if ( $this->home != false ) $tmp->home = $this->home;
        if ( $this->left != false ) $tmp->left = $this->left->menu;
        if ( $this->right != false ) $tmp->right = $this->right->menu;
        if ( $pretty ) {
            return json_encode($tmp, JSON_PRETTY_PRINT);
        } else {
            return json_encode($tmp);
        }
    }
456592
public function json($alternativeHost = null, $pretty = false)
    {
        $this->build($alternativeHost);

        $jsonOptions = JSON_UNESCAPED_SLASHES;

        if ($pretty) {
            $jsonOptions |= JSON_PRETTY_PRINT;
        }

        return json_encode($this->analysis->swagger, $jsonOptions);
    }
82388
public static function encode($value, $options = null)
    {
        if ($options === null) {
            $options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT;
        }

        $json = json_encode($value, $options);

        static::handleJsonError(json_last_error());

        return $json;
    }