feat(eventsub): Add support for channel.moderate Warn (#5932)
* fix(eventsub): Be less strict with strings & vectors
String foo from `{"foo":null}` is now accepted, and returns an empty string
std::vector<String> foo from `{"foo":null}` is now accepted, and returns an empty array
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
{% if field.tag -%}
|
||||
static_assert(false && "JSON tag support is not implemented for vectors");
|
||||
{%- endif %}
|
||||
std::vector<{{field.type_name}}> v{{field.name}};
|
||||
const auto *jv{{field.name}} = root.if_contains("{{field.json_name}}");
|
||||
if (jv{{field.name}} == nullptr)
|
||||
{
|
||||
{% include 'error-missing-field.tmpl' indent content %}
|
||||
if (jv{{field.name}} != nullptr && !jv{{field.name}}->is_null()) {
|
||||
auto {{field.name}} = boost::json::try_value_to<std::vector<{{field.type_name}}>>(*jv{{field.name}});
|
||||
if ({{field.name}}.has_error())
|
||||
{
|
||||
{% include 'error-failed-to-deserialize.tmpl' indent content %}
|
||||
} else {
|
||||
v{{field.name}} = std::move({{field.name}}.value());
|
||||
}
|
||||
}
|
||||
auto {{field.name}} = boost::json::try_value_to<std::vector<{{field.type_name}}>>(*jv{{field.name}});
|
||||
if ({{field.name}}.has_error())
|
||||
{
|
||||
{% include 'error-failed-to-deserialize.tmpl' indent content %}
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
.{{field.name}} = std::move({{field.name}}.value()),
|
||||
.{{field.name}} = std::move(v{{field.name}}),
|
||||
|
||||
Reference in New Issue
Block a user