Skip to content

ohos model to json string garbage characters #4481

@SenyiWong

Description

@SenyiWong

Description

微信截图_20241030172000
微信图片编辑_20241030155950

Reproduction steps

100% reproduction

Expected vs. actual results

struct Person {
std::string name;
int age;
NLOHMANN_DEFINE_TYPE_INTRUSIVE(Person, name, age)
};

Person person;
person.name = "中文字符";
person.age = 23;
nlohmann::json js = person;
const char *str = js.dump().c_str();

js.dump().c_str(); This will make the string garbled

but js.dump() assignment to std::string show the correct string

Minimal code example

No response

Error messages

No response

Compiler and operating system

ohos 5.0

Library version

current version

Validation

Metadata

Metadata

Assignees

No one assigned

    Labels

    solution: invalidthe issue is not related to the library

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions