Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

252
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!