-
Notifications
You must be signed in to change notification settings - Fork 0
/
test14.js
67 lines (23 loc) · 912 Bytes
/
test14.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
Param <__re_middle_result.result[0].user_data.roles> replaced by <["运营管理"]>.
if(typeof value === 'object'){
value = JSON.stringify(value);
}
logger.info('Param <' + variable + '> replaced by <' + value + '>.');
value_string = value_string.replace(variable, value);
//{"data.name":{"$in":"__re_middle_result.id"}
*/
let obj = {"data.name":{"$in":"$to_array('__re_middle_result.id')"}};
let re = /__re_middle_result\.[\w_\-.\[\]]+/gi;
value_string = JSON.stringify(obj);
let variables = value_string.match(re);
// let value = "1";
// let value = "abc";
// let value = 1; //ok
// let value = '["1","2"]'; //ok
let value = '{"id":"123"}'; //ok
console.log(value);
console.log(value_string.replace(variables,value));
// console.log(value_string.replace("\"" + variables + "\"",value));
//
// console.log(value_string.replace(variables,value));