For a long time I used try - catch to be sure that a string is a valid JSON. Today I found that JSON.parse(1) (a number) returns 1 and JSON.parse("123") returns "123" while I expect a syntax error like: Expecting '{', '['.
Even this answer doesn't seem to solve my problem.
So, the question is: can JSON.parse() indicate if the argument that I pass there has a correct JSON format or not?
If not, which is the alternative?