Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[struct_json, struct_yaml][feat]support escape during serialization #581

Merged
merged 1 commit into from
Jan 29, 2024

Conversation

bbbgan
Copy link
Contributor

@bbbgan bbbgan commented Jan 28, 2024

Why

#577

support escape during serialization

What is changing

Example

#include <cassert>
#include <iostream>
#include "ylt/struct_json/json_reader.h"
#include "ylt/struct_json/json_writer.h"

struct person {
  std::string name;
  int age;
};
REFLECTION(person, name, age);
void test_escape_serialize() {
  person p{"\t", 20};
  std::string ss;
  struct_json::to_json(p, ss);
  std::cout << ss << std::endl;   \\ output:  {"name":"\u5C0F\t\u5F3A","age":20}
  person p1;
  struct_json::from_json(p1, ss);
  assert(p1.name == p.name);
}

@poor-circle poor-circle merged commit 383ba03 into alibaba:main Jan 29, 2024
30 checks passed
@poor-circle
Copy link
Collaborator

poor-circle commented Jan 29, 2024

TODO: struct_xml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants