ibireme/yyjson

yyjson_read_opts doesn't accept const char *

Closed this issue · 1 comments

Any reason why yyjson_read_opts doesn't accept const char *?
I have to cast:

yyjson_doc *parse(std::string_view inputString) {
    yyjson_read_flag flags = 0;
    yyjson_read_err error;
    auto jsonDoc = yyjson_read_opts((char *)inputString.data(), inputString.length(), flags, nullptr, &error);

It's documented here:

yyjson/src/yyjson.h

Lines 679 to 681 in 31b0bb4

The `dat` will not be modified without the flag `YYJSON_READ_INSITU`, so you
can pass a `const char *` string and case it to `char *` if you don't use
the `YYJSON_READ_INSITU` flag.

Since this function will modify the input string with the YYJSON_READ_INSITU option, this parameter cannot be declared const.