Sometimes, we want to convert returned JSON object properties to lower first camelCase with JavaScript.
In this article, we’ll look at how to convert returned JSON object properties to lower first camelCase with JavaScript.
How to convert returned JSON object properties to lower first camelCase with JavaScript?
To convert returned JSON object properties to lower first camelCase with JavaScript, we can use the Lodash mapKeys
and camelCase
functions.
For instance, we write
_.mapKeys(obj, (v, k) => _.camelCase(k));
to call mapKeys
with obj
and a callback that calls camelCase
on key k
to convert the keys in obj
to camel case.
Conclusion
To convert returned JSON object properties to lower first camelCase with JavaScript, we can use the Lodash mapKeys
and camelCase
functions.