- Notifications
You must be signed in to change notification settings - Fork7.1k
Accessing JSON keys#5810
-
I want to access and edit a nested key in the json, not the value. I tried unsetting the key value pair and setting a new pair with the key changed but this will add the new pair to the end of the json, i want to preserver the order of the json. Is this supported? |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 1 comment
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Yes, Lodash provides methods to manipulate nested keys in an object while preserving the order. One approach is to use the _.unset() function to remove the nested key, and then use the _.set() function to set a new value with the desired key in the same position. Here's an example: which will output |
BetaWas this translation helpful?Give feedback.