Categories
JavaScript Answers

How to convert returned JSON object properties to lower first camelCase with JavaScript?

Spread the love

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.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.