We are receiving an input parameter value as a pipe-delimited key-value pair, separated with = symbols. For example:
=
\"|User=0101|Name=ImNewUse
You don't need the outer pipes. If necessary, trim them off str.slice(1, str.length - 1)
str.slice(1, str.length - 1)
const str = "User=0101|Name=ImNewUser|IsAdmin=0|RefId=23ae2123cd223bf235"; str.split('|').reduce((accum, x) => { const kv = x.split('='); return {...accum, ...{[kv[0]]: kv[1]}}; }, {})