|
|
|
|
|
by andrewf
529 days ago
|
|
Putting this in my web console: let susJsonString=JSON.stringify(JSON.stringify(JSON.stringify({foo:1})))
console.log("initial:", susJsonString);
try {
while(typeof susJsonString==='string') {
susJsonString = JSON.parse(susJsonString);
console.log("iteration:", typeof susJsonString, susJsonString);
}
} catch {
susJsonString = {};
}
I see: initial: "\"{\\\"foo\\\":1}\""
iteration: string "{\"foo\":1}"
iteration: string {"foo":1}
iteration: object {foo: 1}
A comment explaining the sort of "sus" input it was designed to cope with may have been helpful. |
|