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

140
Visualizações
Serialization of numerical values in JSON

I noticed that https://jwt.io/ outputs the same Base64 string for payloads that contain numerical values written in different notations. For example, these two payloads result in the same Base64 string:

{
  "value": 0.000001
}
{
  "value": 1.0e-6
}

Both produce: eyJ2YWx1ZSI6MC4wMDAwMDF9 Which after decoding displays as: {"value":0.000001}

Where can I find more information about this? I guess there is a specification for this in the form of RFC or something similar. Informal resources on a related subject are also appreciated!

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

0

It doesn't matter how you have created a number. I mean which notation has been used for number literal. The internal representation is IEEE 754. When the serialization happens both values are the same. So the same serialization output is expected.

As of the way number is serialized to a string you can read the Spec. TLDR it depends on the number of significant digits

console.log(1e-6 === .000001)

console.log(JSON.stringify(1e-6), 1e-6.toString())
console.log(JSON.stringify(1e-7), 1e-7.toString())

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