题目说明
编写 function solution(logs, fields)。输入输出均为 JSON 值,不要修改输入数组或对象。不支持外部库、网络访问及异步函数。 logs:JSON[], fields:string[]. Match object keys case-insensitively against fields without trimming. Replace the entire matching value with '[REDACTED]'. Recurse into other objects and arrays; retain primitives and null. Preserve all keys, including '__proto__'. Maximum depth 20. Return a new array in input order. 输入范围:每个输入数组最多50,000项,每个字符串最多1,000个字符。数字必须有限,整数及整数累计结果在JavaScript安全整数范围内。其他类型和有效性遵循上述规则。
输入输出示例
示例 1
函数参数
[
[
{
"token": "abc",
"message": "ok"
}
],
[
"token"
]
]返回值
[
{
"token": "[REDACTED]",
"message": "ok"
}
]示例 2
函数参数
[
[
{
"nested": {
"PASSWORD": "p"
},
"tags": [
"x"
]
}
],
[
"password"
]
]返回值
[
{
"nested": {
"PASSWORD": "[REDACTED]"
},
"tags": [
"x"
]
}
]示例 3
函数参数
[
[
{
"user": {
"name": "Alex"
},
"token": null
}
],
[
"token"
]
]返回值
[
{
"user": {
"name": "Alex"
},
"token": "[REDACTED]"
}
]