return ret == 0 ? used : end + ret;
}
+/*
+ * Add a new element with raw JSON value to the JSON array stored in the
+ * provided buffer.
+ */
+static inline int
+rte_tel_json_add_array_json(char *buf, const int len, const int used,
+ const char *str)
+{
+ int ret, end = used - 1; /* strip off final delimiter */
+ if (used <= 2) /* assume empty, since minimum is '[]' */
+ return __json_snprintf(buf, len, "[%s]", str);
+
+ ret = __json_snprintf(buf + end, len - end, ",%s]", str);
+ return ret == 0 ? used : end + ret;
+}
+
/**
* Add a new element with uint64_t value to the JSON object stored in the
* provided buffer.
return ret == 0 ? used : end + ret;
}
+/**
+ * Add a new element with raw JSON value to the JSON object stored in the
+ * provided buffer.
+ */
+static inline int
+rte_tel_json_add_obj_json(char *buf, const int len, const int used,
+ const char *name, const char *val)
+{
+ int ret, end = used - 1;
+ if (used <= 2) /* assume empty, since minimum is '{}' */
+ return __json_snprintf(buf, len, "{\"%s\":%s}", name, val);
+
+ ret = __json_snprintf(buf + end, len - end, ",\"%s\":%s}",
+ name, val);
+ return ret == 0 ? used : end + ret;
+}
+
#endif /*_RTE_TELEMETRY_JSON_H_*/