Hey,

While I'm not opposed to the idea, I'm struggling to think of a way to 
accurately determine whether a string is true JSON that doesn't involve some 
sort of parsing.

Sure some regexes can be run on it, but I'm not sure that will ever be 100% 
accurate. Any parsing of the JSON to determine whether or not it's valid JSON 
would, in most situations, lead down a code path that then parsed the JSON 
again, essentially repeating the same function for little benefit.

I personally like to use the *`JSON_THROW_ON_ERROR`* flag on json_decode.

Not trying to rain on your parade, so sorry if it comes across that way, I'm 
just not sure of a way to do it where the benefit outweighs the cons, but then 
again, there are people a lot smarter than me on this list.

---
Best Regards,
*Ollie Read*

Reply via email to