Re: [PHP-DEV] RFC Idea - is_json - looking for feedback

2022-08-01 Thread David Gebler
On Sun, Jul 31, 2022 at 4:41 PM Larry Garfield wrote: > So the core argument, it seems, is "there's lots of user-space > implementations already, hence demand, and it would be > better/faster/stronger/we-have-the-technology to do it in C." > There's innumerable features implemented in userland w

Re: [PHP-DEV] RFC Idea - is_json - looking for feedback

2022-07-31 Thread Jordan LeDoux
On Sun, Jul 31, 2022 at 11:23 AM juan carlos morales < dev.juan.mora...@gmail.com> wrote: > - Benchmark including memory_get_peak_usage - > > # json_decode() > > Megas used before call: 79.23828125 > PEAK Megas used before call: 128.00390625 //< > Megas used after call: 3269.23828125 >

Re: [PHP-DEV] RFC Idea - is_json - looking for feedback

2022-07-31 Thread Juan Basso
I think the arguments are good enough for the RFC. However, I would like to propose using a different API. Instead of creating a new global function that could conflict with existing applications, use filter_var validations since it is basically a validation. You can do something like filter_var($p

Re: [PHP-DEV] RFC Idea - is_json - looking for feedback

2022-07-31 Thread juan carlos morales
Hi Juan, > > Thanks for your efforts, and examples. > > You are solving a common use case, in frameworks, libs, and general > userland. > > This much needed function will see good perf/memory improvements once > adoption of is_json() hits popular libs and frameworks. > > I will be voting in favor o

Re: [PHP-DEV] RFC Idea - is_json - looking for feedback

2022-07-31 Thread juan carlos morales
(I received an email from mailer-dae...@lists.php.net , I had to cut the message history as the mail server complained because the email got too long) Larry, here is the same benchmark including memory_get_peak_usage as requested (more after the benchmark) - Benchmark including memory_get_pe

Re: [PHP-DEV] RFC Idea - is_json - looking for feedback

2022-07-31 Thread Larry Garfield
On Sun, Jul 31, 2022, at 8:14 AM, juan carlos morales wrote: > Before starting, I want to thank all for taking time from your time, to > give me a feedback, I sincerely respect that, so ... thanks! > > Sorry for the long message, but I have the feeling that ... this is it, is > now ... or it will

Re: [PHP-DEV] RFC Idea - is_json - looking for feedback

2022-07-31 Thread juan carlos morales
El dom, 31 jul 2022 a las 0:56, Deleu () escribió: > > > On Sat, Jul 30, 2022, 4:48 PM David Gebler wrote: > >> >> >> What I'm asking is what's the practical use for this proposed function? >> Where are you likely to need to know if a string is valid JSON but not >> have >> to (try to, with error

Re: [PHP-DEV] RFC Idea - is_json - looking for feedback

2022-07-30 Thread Deleu
On Sat, Jul 30, 2022, 4:48 PM David Gebler wrote: > > > What I'm asking is what's the practical use for this proposed function? > Where are you likely to need to know if a string is valid JSON but not have > to (try to, with error handling) parse it almost immediately afterwards > anyway? > I'm

Re: [PHP-DEV] RFC Idea - is_json - looking for feedback

2022-07-30 Thread juan carlos morales
El sáb., 30 de julio de 2022 16:48, David Gebler escribió: > > > On Sat, Jul 30, 2022 at 3:01 PM Nikita Popov wrote: > >> On Fri, Jul 29, 2022 at 4:27 PM juan carlos morales < >> dev.juan.mora...@gmail.com> wrote: >> >> > I am following the RFC guideline for the first time. ( >> > https://wiki.p

Re: [PHP-DEV] RFC Idea - is_json - looking for feedback

2022-07-30 Thread David Gebler
On Sat, Jul 30, 2022 at 3:01 PM Nikita Popov wrote: > On Fri, Jul 29, 2022 at 4:27 PM juan carlos morales < > dev.juan.mora...@gmail.com> wrote: > > > I am following the RFC guideline for the first time. ( > > https://wiki.php.net/rfc/howto) > > > > As suggested there, I am here to get a feeling

Re: [PHP-DEV] RFC Idea - is_json - looking for feedback

2022-07-30 Thread Nikita Popov
On Fri, Jul 29, 2022 at 4:27 PM juan carlos morales < dev.juan.mora...@gmail.com> wrote: > I am following the RFC guideline for the first time. ( > https://wiki.php.net/rfc/howto) > > As suggested there, I am here to get a feeling from you, regarding the > following RFC for PHP. > > # Change (draf

Re: [PHP-DEV] RFC Idea - is_json - looking for feedback

2022-07-30 Thread juan carlos morales
El sáb., 30 de julio de 2022 11:58, Oleksii Bulba escribió: > > $memoryAfter = memory_get_usage(true) / 1024 / 1024; > > I see that you used `memory_get_usage` that shows memory usage at the time > of the function call. > As far as I understand, your function does not return any value, > so I sus

Re: [PHP-DEV] RFC Idea - is_json - looking for feedback

2022-07-30 Thread Oleksii Bulba
> $memoryAfter = memory_get_usage(true) / 1024 / 1024; I see that you used `memory_get_usage` that shows memory usage at the time of the function call. As far as I understand, your function does not return any value, so I suspect that it is obvious that the memory usage after the function call is

Re: [PHP-DEV] RFC Idea - is_json - looking for feedback

2022-07-29 Thread juan carlos morales
El sáb, 30 jul 2022 a las 8:30, Dusk () escribió: > On Jul 29, 2022, at 23:05, Aleksander Machniak wrote: > > json_decode() has $depth argument, I think is_json() probably also > should. And I'm not sure about JSON_INVALID_UTF8_IGNORE flag. > > > > My point is that if you use these with json_deco

Re: [PHP-DEV] RFC Idea - is_json - looking for feedback

2022-07-29 Thread juan carlos morales
Just want to clarify that when I mentioned the use of memory, I wrote down the function "memory_get_usage()", which basically gives us the memory handle by php that is related to the memory_limit INI setting. Now I will provide a benchmark I have done really quick: # Code used (I have the impleme

Re: [PHP-DEV] RFC Idea - is_json - looking for feedback

2022-07-29 Thread Dusk
On Jul 29, 2022, at 23:05, Aleksander Machniak wrote: > json_decode() has $depth argument, I think is_json() probably also should. > And I'm not sure about JSON_INVALID_UTF8_IGNORE flag. > > My point is that if you use these with json_decode() you might also need to > use these with is_json()

Re: [PHP-DEV] RFC Idea - is_json - looking for feedback

2022-07-29 Thread Aleksander Machniak
On 29.07.2022 16:26, juan carlos morales wrote: is_json(string $string): bool json_decode() has $depth argument, I think is_json() probably also should. And I'm not sure about JSON_INVALID_UTF8_IGNORE flag. My point is that if you use these with json_decode() you might also need to use the

Re: [PHP-DEV] RFC Idea - is_json - looking for feedback

2022-07-29 Thread Jordan LeDoux
On Fri, Jul 29, 2022 at 7:27 AM juan carlos morales < dev.juan.mora...@gmail.com> wrote: > # Why this function ? > > At the moment the only way to determine if a JSON-string is valid we have > to execute the json_decode() function. > > The drawback about this, is that json_decode() generates an in

Re: [PHP-DEV] RFC Idea - is_json - looking for feedback

2022-07-29 Thread juan carlos morales
El vie, 29 jul 2022 a las 22:18, David Rodrigues () escribió: > I was about to say NO, but after being completely your argument, the idea > makes sense. > > Initially I thought about using json_decode() with error capture, but the > idea that it would overload memory makes perfect sense, compared

Re: [PHP-DEV] RFC Idea - is_json - looking for feedback

2022-07-29 Thread David Rodrigues
I was about to say NO, but after being completely your argument, the idea makes sense. Initially I thought about using json_decode() with error capture, but the idea that it would overload memory makes perfect sense, compared to a simple structure analysis, if that is indeed the user's intention.

Re: [PHP-DEV] RFC Idea - is_json - looking for feedback

2022-07-29 Thread Michał Marcin Brzuchalski
Hi Juan, pt., 29 lip 2022, 16:26 użytkownik juan carlos morales < dev.juan.mora...@gmail.com> napisał: > I am following the RFC guideline for the first time. ( > https://wiki.php.net/rfc/howto) > > As suggested there, I am here to get a feeling from you, regarding the > following RFC for PHP. > >

[PHP-DEV] RFC Idea - is_json - looking for feedback

2022-07-29 Thread juan carlos morales
I am following the RFC guideline for the first time. ( https://wiki.php.net/rfc/howto) As suggested there, I am here to get a feeling from you, regarding the following RFC for PHP. # Change (draft): New function in php called like: is_json(string $string): bool ## Description ### Parameters st