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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *