For such a business requirement, the background returns a string of json data for displaying information, and can modify the value corresponding to the json key, and then save the modified json data.
Similar to the json viewer, a friend gave me an idea, which is to first determine whether the json data is an array and whether there are sub-elements, and then determine whether it is an object. If there are sub-elements, recursion must be used. . . However, I still don’t know how to do it, so I’d like to ask a master for advice. Please help me solve it.
Attached is a diagram of the json viewer
Baidu/Google
js recursively traverses json
A lotIf you modify a node key, you know the key to be modified, and then save the value. The user enters a new key, assigns the key the value you just saved, and then deletes the original key