public static function encode($array, $options = null)
    {
        $result = false;
        $highPrecisionFloatMap = static::getHighPrecisionFloatMap($array);

        if (version_compare(PHP_VERSION, '5.4', '>=')) {
            $jsonOptions = JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES;
            if (!empty($options)) {
                foreach ($options as $o) {
                    $jsonOptions += $o;
                }
            }
            $result = json_encode($array, (int)$jsonOptions);
        } else {
            $result = json_encode($array);

            // Unicode fix: http://stackoverflow.com/a/2934602
            $result = preg_replace_callback(
                '/\\\\u([0-9a-f]{4})/i',
                function ($match) {
                    return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
                },
                $result
            );
            // Escaped slashes fix
            $result = str_replace('\/', '/', $result);
        }

        foreach($highPrecisionFloatMap as $scientificValueString => $floatValueString) {
            // Replace all scientific values by equivalent floatValues
            $result = str_ireplace($scientificValueString, $floatValueString, $result);
        }
        return $result;
    }