0

If I got an object like

{"name":12, "name2":15}

how can I get those values 12 and 15 to be string values instead of number values ?

It's important to mention I'm not creating this object manually and I cannot just add "" right now, api is sending those values and I need them to be converted to string values.

Thanks.

Perp
  • 364
  • 7
  • 15
  • The duplicate seems quite harsh since @Perp, I think, is more concerned about how to reach each value than how to convert them... anyway : `for(var key in obj) obj[key] = obj[key].toString();` is what you're looking for – Boris Jan 22 '17 at 19:13
  • Thanks, Boris, I guess that was it :D – Perp Jan 22 '17 at 19:13
  • you can convert them downstream as `String(obj[key])` instead of just `obj[key]` – dandavis Jan 22 '17 at 19:44

0 Answers0