Re: Re: RFC Idea - is_json - looking for feedback

From: Date: Sun, 07 Aug 2022 12:02:40 +0000
Subject: Re: Re: RFC Idea - is_json - looking for feedback
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-118365@lists.php.net to get a copy of this message
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*

« previous php.internals (#118365) next »