js-convert-case icon indicating copy to clipboard operation
js-convert-case copied to clipboard

Possible to convert an array directly?

Open jimmiejackson414-zz opened this issue 3 years ago • 1 comments

Just discovered that I'm unable to convert an array unfortunately.

const data = [
  { id: 1, user_id: 1, created_at: '2021-07-20T15:40:20.170121+00:00'}, 
  {id: 2, user_id: 2, created_at: '2021-07-20T15:40:20.170121+00:00'},
];

const response = camelKeys(data, {
  recursive: true,
  recursiveInArray: true,
});
console.log(response); // returns null

Are there any plans to allow for this feature?

jimmiejackson414-zz avatar Aug 03 '21 19:08 jimmiejackson414-zz

Hi @jimmiejackson414,

Sorry for the late reply. For your case, since your data type is structured, a workaround can be as follows

const response = data.map(x => camelKeys(x))

huynhsamha avatar Aug 07 '21 10:08 huynhsamha