File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,27 @@ std::string JsonArray::getString(int item) {
175
175
} // getString
176
176
177
177
178
+ /* *
179
+ * @brief Convert the JSON array to a string.
180
+ * @return A JSON string representation of the array.
181
+ */
182
+ std::string JsonArray::toString () {
183
+ char *data = cJSON_Print (m_node);
184
+ std::string ret (data);
185
+ free (data);
186
+ return ret;
187
+ } // toString
188
+
189
+
190
+ /* *
191
+ * @brief Get the number of elements from the array.
192
+ * @return The int value that represents the number of elements.
193
+ */
194
+ std::size_t JsonArray::size () {
195
+ return cJSON_GetArraySize (m_node);
196
+ } // size
197
+
198
+
178
199
JsonObject::JsonObject (cJSON* node) {
179
200
m_node = node;
180
201
}
Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ class JsonArray {
44
44
void addInt (int value);
45
45
void addObject (JsonObject value);
46
46
void addString (std::string value);
47
+ std::string toString ();
48
+ std::size_t size ();
47
49
/* *
48
50
* @brief The underlying cJSON node.
49
51
*/
You can’t perform that action at this time.
0 commit comments