Untitled
unknown
plain_text
3 years ago
1.3 kB
3
Indexable
const data= { "appName": "esa", "clientId": "administrator", "host": "este-rpc-host", "parameters": [ "15000", "2021-01-01T00:00:00Z", "2021-12-31T00:00:00Z", "01-01-1900", "01-01-1900", "01-01-1900", "01-01-1900", "01-01-1900", "01-01-1900", "01-01-1900", "01-01-1900", "01-01-1900", "01-01-1900", "01-01-1900", "01-01-1900", "01-01-1900", "01-01-1900", "01-01-1900", "01-01-1900", "01-01-1900", "01-01-1900" ], "password": "welcome", "rpcName": "sap_prod_upd", "userId": "127.30.93.198" } var regex = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/gm; var message = data; for (const key of Object.keys(data)) { if(key ==="parameters"){ console.log(key, data[key]); for(let datum in data[key]){ var regex = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/gm if(data[key][datum].match(regex)){ data[key][datum] = convertdate(data[key][datum]) } } } } function convertdate(word){ var temp = word.slice(0,word.indexOf("T")).split("-"); var date = ""+temp[2]+"-"+temp[1]+"-"+temp[0]; return date } console.log((data))
Editor is loading...