About the problem that the JSON.parse restore function reviver returns undefined?

problem description

I need to process an object, filter out some keys and modify a key value to get the structure I want. Handle it with JSON.parse combined with reviver function. But get the weird result of undefined .

Why can"t the following code get the results I want?
I can get the correct results now, but there are no errors in the following code. Please analyze why I can"t get the results I want.

the environmental background of the problems and what methods you have tried

operating environment: node V9.11.2

related codes

{ 
  id: "5c34650e307f782408c4501b",
  interName: "",
  opt: "mac",
  ruleStr: "00:0A:02:0B:03:0C",
  algorithmOptRules: "afafafafaf"
}
Apr.19,2022

12

because value is empty


use the reviver function

when traversing to the topmost value (parsed value), the argument passed in to the reviver function will be the empty string "". Be aware of this special case when writing reviver functions.
if(key === '') return value;     // 
Menu