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

253
Visualizações
How to display the value without the key after JSON.stringify?

I am trying to display the value of a key after using JSON.stringify to collect form data and put into JSON. Now I need the value of a specific key within from this json file but I get the key/value pair:

{"KEY":"KM8IJM12D56U303366"}

Currently my code to display this is:

const onSubmit = async data => {

    // How to get specific data from stringify
    var jsonString = JSON.stringify(data, ["KEY"]);
    alert(jsonString);
    notify();
};

I have tried using getItem() but that seems to only work with local storage. Is there a solution where I can just directly access the value of KEY after JSON.stringify()?

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

0

Amigo, My first suggestion over this would be, Go with the data as Object, don't stringify that.

const onSubmit = async data => {

    // If data is not a Stringify Object:
    var jsonString = JSON.stringify(data.key);
    alert(jsonString);
    notify();

    //********

    // If data is a Stringify Object:
    var jsonString = JSON.parse(data);
    alert(jsonString.key);
    notify();


    
};

But If you want to go with a string:

const onSubmit = async data => {
    // If you want to use only the Key as a string, go with the line below
    var jsonString = data.key.toString();

    // Else Directly access your key by the below line.
    var jsonString = data.key;

    alert(jsonString);
    notify();
};
about 4 years ago · Juan Pablo Isaza Relatório

0

You would need to JSON.parse() it back to an object to access keys and values. After you apply stringify(), it's a string.

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