private static function replaceArrayByMap($json, array $arrayKeys)
    {
        preg_match_all(self::ARRAY_KEYS_REGEX, $json, $matches, PREG_SET_ORDER);

        foreach ($matches as $match) {
            if (!\in_array($match[1], $arrayKeys, true)) {
                $replace = str_replace('[]', '{}', $match[0]);
                $json = str_replace($match[0], $replace, $json);
            }
        }

        return $json;
    }
private static function replaceArrayByMap($json, array $arrayKeys)
    {
        preg_match_all(self::ARRAY_KEYS_REGEX, $json, $matches, PREG_SET_ORDER);

        foreach ($matches as $match) {
            if (!\in_array($match[1], $arrayKeys, true)) {
                $replace = str_replace('[]', '{}', $match[0]);
                $json = str_replace($match[0], $replace, $json);
            }
        }

        return $json;
    }
private static function replaceArrayByMap ( $ json , array $ arrayKeys ) { preg_match_all ( self :: ARRAY_KEYS_REGEX , $ json , $ matches , PREG_SET_ORDER ) ; foreach ( $ matches as $ match ) { if ( ! \ in_array ( $ match [ 1 ] , $ arrayKeys , true ) ) { $ replace = str_replace ( '[]' , '{}' , $ match [ 0 ] ) ; $ json = str_replace ( $ match [ 0 ] , $ replace , $ json ) ; } } return $ json ; }
Replace the empty array by empty map.

@param string   $json      The original JSON
@param string[] $arrayKeys The list of keys to be retained with an array representation if they are empty

@return string
Replace the empty array by empty map .