This is processed data(INPUT).
这是处理过的数据(INPUT)。
[['dObjectData.question':{ '$regex': '^(abc)', '$options': 'i'}],
['dObjectData.answer': { '$regex': '.*(pqr).*','$options': 'i' }]]
I want to make(modified this process data) in this format(OUTPUT).
我想以这种格式(OUTPUT)制作(修改此过程数据)。
[{'dObjectData.question':{'$regex':'^(abc)','$options':'i'},
'dObjectData.answer':{'$regex': '.*(pqr).*', '$options':'i'}]
1 个解决方案
#1
0
You can try like that:
你可以尝试这样:
x = [
[
'dObjectData.question', {
'$regex': '^(abc)',
'$options': 'i'
}
],
[
'dObjectData.answer', {
'$regex': '.*(pqr).*',
'$options': 'i'
}
]
]
o = x.reduce(function (p, c) {
p[c[0]] = c[1];
return p;
}, [])
console.log(o)
The output like that:
像这样的输出:
[ 'dObjectData.question': { '$regex': '^(abc)', '$options': 'i' },
'dObjectData.answer': { '$regex': '.*(pqr).*', '$options': 'i' } ]
#1
0
You can try like that:
你可以尝试这样:
x = [
[
'dObjectData.question', {
'$regex': '^(abc)',
'$options': 'i'
}
],
[
'dObjectData.answer', {
'$regex': '.*(pqr).*',
'$options': 'i'
}
]
]
o = x.reduce(function (p, c) {
p[c[0]] = c[1];
return p;
}, [])
console.log(o)
The output like that:
像这样的输出:
[ 'dObjectData.question': { '$regex': '^(abc)', '$options': 'i' },
'dObjectData.answer': { '$regex': '.*(pqr).*', '$options': 'i' } ]