I want to construct an object array with key-value pair from a string array.
the string array format:
['<ISO Date> - <Log Level> - {"user_id: "<UUID>", "details": "<message event/action description>", "err": "<Optionall, error description>"}']
the object array format:
[{"timestamp": <Epoch Unix Timestamp>, "loglevel": "<loglevel>", "transactionId: "<UUID>", "err": "<Error message>" }]
stringArray = [
"2021-08-09T02:12:51.259Z - error - {\"user_id\":\"1234-1111\",\"details\":\"Cannot find user orders list\",\"code\": 404,\"err\":\"Not found\"}",
"2022-08-09T02:12:51.275Z - error - {\"user_id\":\"1111-1234\",\"details\":\"Cannot find user orders list\",\"code\":404,\"err\":\"Cannot find user orders list"}"
];
objectArray = [
{
"timestamp":1628475171259,
"loglevel":"error",
"userId":"1234-1111",
"err":"Not found"
},
{
"timestamp":1660011171275,
"loglevel":"error",
"userId":"1111-1234",
"err":"Cannot find user orders list"
}
];