Better JSON macros

Đang mở
#4,091 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
cpp
Lĩnh vực
backend-api-design

Hướng nghiên cứu

Issue không nêu tên bất kỳ tệp, bài kiểm thử hay điểm vào nào. Hãy bắt đầu bằng cách xác định các khai báo macro JSON hiện tại cùng với các phần triển khai tuần tự hóa và giải tuần tự hóa của chúng, sau đó so sánh hành vi của các trường tùy chọn và độ phức tạp tại thời điểm biên dịch được mô tả ở đây. Để được coi là hoàn tất, cần có một thiết kế lại đã được thống nhất cùng với phần triển khai và các bài kiểm thử tương ứng, nhưng phạm vi chưa được xác định.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

There's a few issues with our current JSON macros:

  • Forces conflation of serialisation and deserialisation. A field is either required (always present in serialisations, must be present to deserialise), or optional (may be omitted when serialising, allowed to be missing when deserialising). This misses the behaviour we'd actually like for most new fields added to existing types, which is that they are always serialised to new JSON objects, but may be missing from old JSON objects. This in turn leads to the confusing interplay between std::optional wrappers and OPTIONAL macro declarations.
  • Repetition of optionality. To add an optional field to a type which previously only had required fields, you must add a DECLARE_JSON_OPTIONAL_FIELDS line and also change the original declaration from DECLARE_JSON_TYPE to DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS. This is a complex, non-obvious change, and is a hard-to-debug runtime weirdness if you forget the latter.
  • Compile-time complexity. The implementation of these macros combines overloaded ADL dispatched functions and some template specializations, producing a large amount of code for the compiler to churn through.
  • Maintenance complexity. I barely understand it, and I wrote it. Adding new features is tricky, and likely to increase the matrix of initial declaration macros.

I think we can and should do better on all of these. These are primarily issues for framework developers rather than application developers, so not an immediate priority, but they are exposed for application developers to use so their API must be correctly exposed.

Ngôn ngữ chính
C++
Star
876
Fork
264
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
138

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/CCF

Tất cả issue của microsoft/CCF

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.