I receive a JSON object that looks like this: this data is being passed through a Socketio emit, so the angular HttpClient is not intercepting it.
{
"single":[
{
"name":"Xavi555",
"data":[
{
"_id":"5e2ea609f8c83e5435ebb6e5",
"id":"test1",
"author":"someone",
"recipient":"someone",
"content":"test",
"msgId":"Testid",
"gNamespace":""
}
]
}
],
"group":[]
}
however when I use JSON.parse()
on the object above The key data
does not contain the value of data
that is to say:
private func(jsonObj: string): void {
console.log(jsonObj);
}
I see:
single: Array(1)
groups: Array(0)
single Array(1)
name: test
data: Array(0)
I thought it was an issue with deep cloning, but, when trying to do JSON.parse(JSON.stringify(jsonObj))
it returns the original json string object.
related but no solution posted
private handleStoredMessages(dirtyObj: string): void {
// debugger;
const cleanObj = JSON.parse(dirtyObj);
const { single, group } = cleanObj;
console.log('raw json', dirtyObj);
onsole.log('clean json', cleanObj);
}
any ideas?