make the message rating field (from ENGINE-959) a scalar, for consistency

Serialise and deserialise the new rating field of message.  This is
backward-compatible and does not affect function arguments, differently from
earlier iterations of the ENGINE-959 change set.

The new field has an enum type and is therefore serialised as a JSON non-scalar,
as per the conventions in .
positron 1 year ago
parent 2503654ab6
commit c2483cf1e9

@ -252,8 +252,7 @@ message* from_json<message*>(const js::Value& v)
msg->comments = from_json_object<char*, js::str_type>(o, "comments");
msg->opt_fields = from_json_object<stringpair_list_t*, js::array_type>(o, "opt_fields");
msg->enc_format = from_json_object<PEP_enc_format, js::int_type>(o, "enc_format");
// Serialise to a JSON scalar, not to PEP_rating which is an enum.
msg->rating = PEP_rating(from_json_object<int, js::int_type>(o, "rating"));
msg->rating = from_json_object<PEP_rating, js::obj_type>(o, "rating");
return msg.release();
@ -347,7 +346,7 @@ js::Value to_json<message const*>(message const* const& msg)
to_json_object(o, "comments", msg->comments);
to_json_object(o, "opt_fields", msg->opt_fields);
to_json_object(o, "enc_format", msg->enc_format);
to_json_object(o, "rating", int(msg->rating)); // We want a JSON scalar.
to_json_object(o, "rating", msg->rating);
return js::Value( std::move(o) );