nlohmann / json

JSON for Modern C++
https://json.nlohmann.me
MIT License
42.97k stars 6.72k forks source link

Parse doesnt work #3936

Closed volkaris closed 1 year ago

volkaris commented 1 year ago

Description

Cant parse string or const char*

Reproduction steps

setlocale(LC_ALL, "Rus"); using json = nlohmann::json;

auto q = R"("AUD": {
        "ID": "R01010",
        "NumCode": "036",
        "CharCode": "AUD",
        "Nominal": 1,
        "Name": "Австралийский доллар",
        "Value": 49.6231,
        "Previous": 49.3551
    })";

string str1 = q;
size_t start_pos = str1.find("Австралийский доллар");
str1.replace(start_pos, strlen("Австралийский доллар"), "aus");
q = str1.c_str();
cout << q;
auto j = json::parse(q);

Expected vs. actual results

Error!!

Minimal code example

No response

Error messages

No response

Compiler and operating system

windows

Library version

latest

Validation

nlohmann commented 1 year ago

You did not provide the exception message. I bet it has to do with encoding. The library only supports UTF-8. See https://json.nlohmann.me/home/faq/#parse-errors-reading-non-ascii-characters