Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

215
Visualizações
Why does JSON.stringify() \u30FC to ー

I tried the code below:

console.log(JSON.stringify({ test: "\u30FCabc" }));

It gives the output below:

'{"test":"ーabc"}'

We know that mainly JSON.stringify() method converts a JavaScript object or value to a JSON string. And as per JSON std (https://www.json.org/json-en.html) we should be able to store \u30FC. Then why "\u30FC" is converted to "ー"?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Then why "\u30FC" is converted to "ー" ?

  1. The JavaScript engine reads your string literal and does that conversion to create the in-memory string
  2. The object containing that string is passed to JSON.stringify
  3. JSON.stringify encodes the object as JSON and represents the ー as a literal ー because JSON.stringify was written in such a way to prefer literal characters over escape sequences where the JSON data format allows either.

Some JSON encoders let you control this, for example, in PHP, compare:

<?php echo json_encode('ーabc', JSON_UNESCAPED_UNICODE); ?>

and

<?php echo json_encode('ーabc'); ?>

… but JavaScript's JSON.stringify doesn't have any such option.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda