json: simplify JSON_VARIANT_OBJECT_FOREACH() macro a bit
There's no point in returning the "key" within each loop iteration as JsonVariant object. Let's simplify things and return it as string. That simplifies usage (since the caller doesn't have to convert the object to the string anymore) and is safe since we already validate that keys are strings when an object JsonVariant is allocated.
This commit is contained in:
+1
-1
@@ -143,7 +143,7 @@ struct json_variant_foreach_state {
|
||||
#define JSON_VARIANT_OBJECT_FOREACH(k, e, v) \
|
||||
for (struct json_variant_foreach_state _state = { (v), 0 }; \
|
||||
_state.idx < json_variant_elements(_state.variant) && \
|
||||
({ k = json_variant_by_index(_state.variant, _state.idx); \
|
||||
({ k = json_variant_string(json_variant_by_index(_state.variant, _state.idx)); \
|
||||
e = json_variant_by_index(_state.variant, _state.idx + 1); \
|
||||
true; }); \
|
||||
_state.idx += 2)
|
||||
|
||||
Reference in New Issue
Block a user