Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

100
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda