ibireme / yyjson

The fastest JSON library in C
https://ibireme.github.io/yyjson/doc/doxygen/html/
MIT License
3.04k stars 262 forks source link

yyjson_read_opts doesn't accept const char * #93

Closed dan-ryan closed 2 years ago

dan-ryan commented 2 years ago

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);
ibireme commented 2 years ago

It's documented here: https://github.com/ibireme/yyjson/blob/31b0bb4b521d9c16b9e56e151fc92c9cb844b6eb/src/yyjson.h#L679-L681

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