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

99
Views
Replace entire JSON file key values with empty strings

I have a list of flat JSON keys and values. I am trying to replace all the key values with empty strings

Here is my JSON.

{
    "wl.label.accountPin": "Account PIN",
    "wl.label.logon": "Logon details",
    "wl.label.logonDetails": "Logon details",
    "wl.label.password": "Logon details",

    "Sunday": "Sunday",
    "Monday": "Monday",
    "Tuesday": "Tuesday",
    "Wednesday": "Wednesday",
    "Thursday": "Thursday",
    "Friday": "Friday",
    "Saturday": "Saturday",

    "Su": "Su",
    "Mo": "Mo",
    "Tu": "Tu",
    "We": "We",
    "Th": "Th",
    "Fr": "Fr",
    "Sa": "Sa",

    "January": "January",
    "February": "February",
    "March": "March",
    "April": "April",
    "May": "May",
    "June": "June",
    "July": "July",
    "August": "August",
    "September": "September",
    "October": "October",
    "November": "November",
    "December": "December",

    "Jan": "Jan",
    "Feb": "Feb",
    "Mar": "Mar",
    "Apr": "Apr",
    "May": "May",
    "Jun": "Jun",
    "Jul": "Jul",
    "Aug": "Aug",
    "Sep": "Sep",
    "Oct": "Oct",
    "Nov": "Nov",
    "Dec": "Dec"
}

So I want to keep the key names but replace all the key values with empty strings

eg "wl.label.accountPin": "Account PIN", should be "wl.label.accountPin": "",

What would be the best way to do this?

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You json is not json but an Object. Furthermore, it's a one liner. Here's a a minimal reproducable example.

const obj = {
    "wl.label.accountPin": "Account PIN",
    "Sunday": "Sunday",
    "Su": "Su",
    "January": "January",
    "Jan": "Jan",
};

console.log(Object.entries(obj).reduce( (acc, [key,]) => ({...acc, [key]: ""}), {}));

about 4 years ago · Juan Pablo Isaza Report

0

Simple solution

json = {YOUR_DATA};
Object.keys(json).forEach(function(key) {
    json[key] = "";
})

See JSFiddle here http://jsfiddle.net/1xo6pf8s/

about 4 years ago · Juan Pablo Isaza Report

0

Here you go, enjoy and have a good day :)

 var d = {
         'firstKey':'firstValue',
         'secondKey':'secondValue'
        }

for(i in d){
d[i] = ''
}
console.log(d)

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!