D
D
developerrr2015-10-02 19:44:27
JavaScript
developerrr, 2015-10-02 19:44:27

How to replace large letters in json with small letters?

Let's say we have this json:

{'Account': 'Vasja', 'Date': '02/10/2015', 'Id' : '78234324234'}

I need Account, Date and Id to start with a small letter if they are capitalized in the received json. Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly Inchin ☢, 2015-10-02
@developerrr

var jsoff = JSON.parse('{"Accoun":"Vasja","Date":"02/10/2015","Id":"78234324234"}'), jp = {};
for(var o in jsoff) jp[o.toLowerCase()] = jsoff[o];

console.log(jp);

Михаил Горячкин, 2015-10-02
@abaddon65

Можно вот так:

var jsonObj = {'Account': 'Vasja', 'Date': '02/10/2015', 'Id' : '78234324234'};
var jsonString = JSON.stringify(jsonObj);
console.log(JSON.parse(jsonString.toLowerCase()));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question