type field_##name = static_cast<type>(def); \
bool field_##name##_found = false; \
(void)field_##name##_found; \
do if (
json.HasMember(#name)) \
{ \
if (
json[#name].Is##jtype()) \
{ \
field_##name =
static_cast<type
>(
json[#name].Get##jtype()); \
field_##name##_found = true; \
} \
else \
{ \
LOG_ERROR("Field " << #name << " found in JSON, but not " << #jtype); \
return false; \
} \
} \
else if (mandatory) \
{ \
LOG_ERROR("Field " << #name << " not found in JSON"); \
return false; \
} while(0)
32#define GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, name, type, jtype, mandatory, def) \
33 type field_##name = static_cast<type>(def); \
34 bool field_##name##_found = false; \
35 (void)field_##name##_found; \
36 do if (json.HasMember(#name)) \
37 { \
38 if (json[#name].Is##jtype()) \
39 { \
40 field_##name = static_cast<type>(json[#name].Get##jtype()); \
41 field_##name##_found = true; \
42 } \
43 else \
44 { \
45 LOG_ERROR("Field " << #name << " found in JSON, but not " << #jtype); \
46 return false; \
47 } \
48 } \
49 else if (mandatory) \
50 { \
51 LOG_ERROR("Field " << #name << " not found in JSON"); \
52 return false; \
53 } while(0)