On Fri, Aug 26, 2022 at 6:29 PM Kamil Tekiela <tekiela...@gmail.com> wrote:
> What is the reasoning behind the name? I can't find it explained in the > RFC. What about other alternatives like is_json or validate_json? > The name json_validate makes most sense to me; it groups itself together nicely with the other json_* API functions. I think is_json is what was originally proposed but besides being then inconsistent with the rest of the JSON API function naming, consider most of the is_* functions are for checking types (and some for file properties), not validation. But on the function, the other question which remains for me is whether returning boolean is the right thing to do at all. It seems obviously intuitive it should, returning true for valid and false for invalid JSON but then if you consider you're still going to be in the situation of calling json_last_error() if you want to know why invalid JSON was invalid and in particular you might not expect the "last error" to have changed just from an attempt to check a string. How can there be an error when by definition you weren't trying to do anything except check the validity of some unknown data? Not sure what the answer is there...curious what other people's views are on that. I don't think throwing an exception on invalid JSON is the right answer in any case.