8 #include "../../libjson.h"
12 #include "JSONWorker.h"
13 #include "JSONValidator.h"
14 #include "JSONStream.h"
15 #include "JSONGlobals.h"
17 #ifdef JSON_MEMORY_MANAGE
18 #define MANAGER_INSERT(x) json_global(NODE_HANDLER).insert(x)
19 #define MANAGER_STREAM_INSERT(x) json_global(STREAM_HANDLER).insert(x)
21 #define MANAGER_INSERT(x) x
22 #define MANAGER_STREAM_INSERT(x) x
25 static const json_char * EMPTY_CSTRING(JSON_TEXT(
""));
27 #ifdef JSON_MEMORY_POOL
28 #include "JSONMemoryPool.h"
29 extern memory_pool<NODEPOOL> json_node_mempool;
32 inline json_char * toCString(
const json_string & str) json_nothrow {
33 const size_t len = (str.length() + 1) *
sizeof(json_char);
34 #ifdef JSON_MEMORY_MANAGE
35 return (json_char *)json_global(STRING_HANDLER).insert(std::memcpy(json_malloc<json_char>(len), str.c_str(), len));
37 return (json_char *)std::memcpy(json_malloc<json_char>(len), str.c_str(), len);
41 inline json_char * alreadyCString(json_char * str) json_nothrow {
42 #ifdef JSON_MEMORY_MANAGE
43 return (json_char *)json_global(STRING_HANDLER).insert(str);
52 void json_free(
void * str){
53 JSON_ASSERT_SAFE(str, JSON_TEXT(
"freeing null ptr"),
return;);
54 #ifdef JSON_MEMORY_MANAGE
55 json_global(STRING_HANDLER).remove(str);
57 libjson_free<void>(str);
60 void json_delete(JSONNODE * node){
61 JSON_ASSERT_SAFE(node, JSON_TEXT(
"deleting null ptr"),
return;);
62 #ifdef JSON_MEMORY_MANAGE
63 json_global(NODE_HANDLER).remove(node);
65 JSONNode::deleteJSONNode((JSONNode *)node);
68 #ifdef JSON_MEMORY_MANAGE
69 void json_free_all(
void){
70 json_global(STRING_HANDLER).clear();
73 void json_delete_all(
void){
74 json_global(NODE_HANDLER).clear();
78 #ifdef JSON_READ_PRIORITY
79 JSONNODE * json_parse(json_const json_char * json){
80 JSON_ASSERT_SAFE(json, JSON_TEXT(
"null ptr to json_parse"),
return 0;);
83 return MANAGER_INSERT(JSONNode::newJSONNode_Shallow(JSONWorker::parse(TOCONST_CSTR(json))));
84 } json_catch (std::invalid_argument, (
void)0; )
85 #ifndef JSON_NO_EXCEPTIONS
90 JSONNODE * json_parse_unformatted(json_const json_char * json){
91 JSON_ASSERT_SAFE(json, JSON_TEXT(
"null ptr to json_parse"),
return 0;);
94 return MANAGER_INSERT(JSONNode::newJSONNode_Shallow(JSONWorker::parse_unformatted(TOCONST_CSTR(json))));
95 } json_catch(std::invalid_argument, (
void)0; )
96 #ifndef JSON_NO_EXCEPTIONS
102 json_char * json_strip_white_space(json_const json_char * json){
103 JSON_ASSERT_SAFE(json, JSON_TEXT(
"null ptr to json_strip_white_space"),
return 0;);
104 return alreadyCString(JSONWorker::RemoveWhiteSpaceAndCommentsC(TOCONST_CSTR(json),
false));
108 #ifdef JSON_DEPRECATED_FUNCTIONS
109 JSONNODE * json_validate(json_const json_char * json){
110 JSON_ASSERT_SAFE(json, JSON_TEXT(
"null ptr to json_validate"),
return 0;);
111 if (json_is_valid(json)){
112 return json_parse(json);
117 json_bool_t json_is_valid(json_const json_char * json){
118 JSON_ASSERT_SAFE(json, JSON_TEXT(
"null ptr to json_is_valid"),
return (json_bool_t)
false;);
119 #ifdef JSON_SECURITY_MAX_STRING_LENGTH
120 if (json_unlikely(json_strlen(json) > JSON_SECURITY_MAX_STRING_LENGTH)){
121 JSON_FAIL(JSON_TEXT(
"Exceeding JSON_SECURITY_MAX_STRING_LENGTH"));
125 json_auto<json_char> s;
126 s.set(JSONWorker::RemoveWhiteSpaceAndCommentsC(json,
false));
127 return (json_bool_t)JSONValidator::isValidRoot(s.ptr);
130 json_bool_t json_is_valid_unformatted(json_const json_char * json){
131 JSON_ASSERT_SAFE(json, JSON_TEXT(
"null ptr to json_is_valid_unformatted"),
return (json_bool_t)
true;);
132 #ifdef JSON_SECURITY_MAX_STRING_LENGTH
133 if (json_unlikely(json_strlen(json) > JSON_SECURITY_MAX_STRING_LENGTH)){
134 JSON_FAIL(JSON_TEXT(
"Exceeding JSON_SECURITY_MAX_STRING_LENGTH"));
138 return (json_bool_t)JSONValidator::isValidRoot(json);
142 #if defined JSON_DEBUG && !defined JSON_STDERROR
144 void json_register_debug_callback(json_error_callback_t callback){
145 JSONDebug::register_callback(callback);
149 #ifdef JSON_MUTEX_CALLBACKS
150 #ifdef JSON_MUTEX_MANAGE
151 void json_register_mutex_callbacks(json_mutex_callback_t lock, json_mutex_callback_t unlock, json_mutex_callback_t destroy,
void * manager_lock){
152 JSONNode::register_mutex_callbacks(lock, unlock, manager_lock);
153 JSONNode::register_mutex_destructor(destroy);
157 void json_register_mutex_callbacks(json_mutex_callback_t lock, json_mutex_callback_t unlock,
void * manager_lock){
158 JSONNode::register_mutex_callbacks(lock, unlock, manager_lock);
162 void json_set_global_mutex(
void * mutex){
163 JSONNode::set_global_mutex(mutex);
166 void json_set_mutex(JSONNODE * node,
void * mutex){
167 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_set_mutex"),
return;);
168 ((JSONNode*)node) -> set_mutex(mutex);
171 void json_lock(JSONNODE * node,
int threadid){
172 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_lock"),
return;);
173 ((JSONNode*)node) -> lock(threadid);
176 void json_unlock(JSONNODE * node,
int threadid){
177 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_unlock"),
return;);
178 ((JSONNode*)node) -> unlock(threadid);
182 #ifdef JSON_MEMORY_CALLBACKS
183 void json_register_memory_callbacks(json_malloc_t mal, json_realloc_t real, json_free_t fre){
184 JSONMemory::registerMemoryCallbacks(mal, real, fre);
189 void json_stream_push(JSONSTREAM * stream, json_const json_char * addendum){
190 (*((JSONStream*)stream)) << addendum;
193 void json_delete_stream(JSONSTREAM * stream){
194 JSON_ASSERT_SAFE(stream, JSON_TEXT(
"deleting null ptr"),
return;);
195 #ifdef JSON_MEMORY_MANAGE
196 json_global(STREAM_HANDLER).remove(stream);
198 JSONStream::deleteJSONStream((JSONStream *)stream);
201 JSONSTREAM * json_new_stream(json_stream_callback_t callback, json_stream_e_callback_t e_callback,
void * identifier){
202 return MANAGER_STREAM_INSERT(JSONStream::newJSONStream(callback, e_callback, identifier));
205 void json_stream_reset(JSONSTREAM * stream){
206 JSON_ASSERT_SAFE(stream, JSON_TEXT(
"resetting null ptr"),
return;);
207 ((JSONStream*)stream) -> reset();
216 JSONNODE * json_new_a(json_const json_char * name, json_const json_char * value){
217 if (!name) name = EMPTY_CSTRING;
218 JSON_ASSERT_SAFE(value, JSON_TEXT(
"null value to json_new_a"), value = EMPTY_CSTRING;);
219 #ifdef JSON_MEMORY_POOL
220 return MANAGER_INSERT(
new((JSONNode*)json_node_mempool.allocate()) JSONNode(TOCONST_CSTR(name), json_string(TOCONST_CSTR(value))));
221 #elif defined(JSON_MEMORY_CALLBACKS)
222 return MANAGER_INSERT(
new(json_malloc<JSONNode>(1)) JSONNode(TOCONST_CSTR(name), json_string(TOCONST_CSTR(value))));
224 return MANAGER_INSERT(
new JSONNode(TOCONST_CSTR(name), json_string(TOCONST_CSTR(value))));
228 JSONNODE * json_new_i(json_const json_char * name, json_int_t value){
229 if (!name) name = EMPTY_CSTRING;
230 #ifdef JSON_MEMORY_POOL
231 return MANAGER_INSERT(
new((JSONNode*)json_node_mempool.allocate()) JSONNode(TOCONST_CSTR(name), value));
232 #elif defined(JSON_MEMORY_CALLBACKS)
233 return MANAGER_INSERT(
new(json_malloc<JSONNode>(1)) JSONNode(TOCONST_CSTR(name), value));
235 return MANAGER_INSERT(
new JSONNode(TOCONST_CSTR(name), value));
239 JSONNODE * json_new_f(json_const json_char * name, json_number value){
240 if (!name) name = EMPTY_CSTRING;
241 #ifdef JSON_MEMORY_POOL
242 return MANAGER_INSERT(
new((JSONNode*)json_node_mempool.allocate()) JSONNode(TOCONST_CSTR(name), value));
243 #elif defined(JSON_MEMORY_CALLBACKS)
244 return MANAGER_INSERT(
new(json_malloc<JSONNode>(1)) JSONNode(TOCONST_CSTR(name), value));
246 return MANAGER_INSERT(
new JSONNode(TOCONST_CSTR(name), value));
250 JSONNODE * json_new_b(json_const json_char * name, json_bool_t value){
251 if (!name) name = EMPTY_CSTRING;
252 #ifdef JSON_MEMORY_POOL
253 return MANAGER_INSERT(
new((JSONNode*)json_node_mempool.allocate()) JSONNode(TOCONST_CSTR(name),
static_cast<bool>(value)));
254 #elif defined(JSON_MEMORY_CALLBACKS)
255 return MANAGER_INSERT(
new(json_malloc<JSONNode>(1)) JSONNode(TOCONST_CSTR(name), static_cast<bool>(value)));
257 return MANAGER_INSERT(
new JSONNode(TOCONST_CSTR(name), static_cast<bool>(value)));
261 JSONNODE * json_new(
char type){
262 #ifdef JSON_MEMORY_POOL
263 return MANAGER_INSERT(
new((JSONNode*)json_node_mempool.allocate()) JSONNode(type));
264 #elif defined(JSON_MEMORY_CALLBACKS)
265 return MANAGER_INSERT(
new(json_malloc<JSONNode>(1)) JSONNode(type));
267 return MANAGER_INSERT(
new JSONNode(type));
271 JSONNODE * json_copy(json_const JSONNODE * orig){
272 JSON_ASSERT_SAFE(orig, JSON_TEXT(
"null orig to json_copy"),
return 0;);
273 #ifdef JSON_MEMORY_POOL
274 return MANAGER_INSERT(
new((JSONNode*)json_node_mempool.allocate()) JSONNode(*((JSONNode*)orig)));
275 #elif defined(JSON_MEMORY_CALLBACKS)
276 return MANAGER_INSERT(
new(json_malloc<JSONNode>(1)) JSONNode(*((JSONNode*)orig)));
278 return MANAGER_INSERT(
new JSONNode(*((JSONNode*)orig)));
282 JSONNODE * json_duplicate(json_const JSONNODE * orig){
283 JSON_ASSERT_SAFE(orig, JSON_TEXT(
"null orig to json_duplicate"),
return 0;);
284 return MANAGER_INSERT(JSONNode::newJSONNode_Shallow(((JSONNode*)orig) -> duplicate()));
288 void json_set_a(JSONNODE * node, json_const json_char * value){
289 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_set_a"),
return;);
290 JSON_ASSERT_SAFE(value, JSON_TEXT(
"null value to json_set_a"), value = EMPTY_CSTRING;);
291 *((JSONNode*)node) = json_string(TOCONST_CSTR(value));
294 void json_set_i(JSONNODE * node, json_int_t value){
295 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_set_i"),
return;);
296 *((JSONNode*)node) = value;
299 void json_set_f(JSONNODE * node, json_number value){
300 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_set_f"),
return;);
301 *((JSONNode*)node) = value;
304 void json_set_b(JSONNODE * node, json_bool_t value){
305 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_set_b"),
return;);
306 *((JSONNode*)node) =
static_cast<bool>(value);
309 void json_set_n(JSONNODE * node, json_const JSONNODE * orig){
310 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_set_n"),
return;);
311 JSON_ASSERT_SAFE(orig, JSON_TEXT(
"null node to json_set_n"),
return;);
312 *((JSONNode*)node) = *((JSONNode*)orig);
317 char json_type(json_const JSONNODE * node){
318 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_type"),
return JSON_NULL;);
319 return ((JSONNode*)node) -> type();
322 json_index_t json_size(json_const JSONNODE * node){
323 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_size"),
return 0;);
324 return ((JSONNode*)node) -> size();
327 json_bool_t json_empty(json_const JSONNODE * node){
328 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_empty"),
return true;);
329 return (json_bool_t)(((JSONNode*)node) -> empty());
332 json_char * json_name(json_const JSONNODE * node){
333 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_name"),
return toCString(EMPTY_CSTRING););
334 return toCString(((JSONNode*)node) -> name());
338 json_char * json_get_comment(json_const JSONNODE * node){
339 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_get_comment"),
return toCString(EMPTY_CSTRING););
340 return toCString(((JSONNode*)node) -> get_comment());
344 json_char * json_as_string(json_const JSONNODE * node){
345 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_as_string"),
return toCString(EMPTY_CSTRING););
346 return toCString(((JSONNode*)node) -> as_string());
350 json_int_t json_as_int(json_const JSONNODE * node){
351 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_as_int"),
return 0;);
352 return ((JSONNode*)node) -> as_int();
356 json_number json_as_float(json_const JSONNODE * node){
357 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_as_float"),
return 0.0f;);
358 return ((JSONNode*)node) -> as_float();
362 json_bool_t json_as_bool(json_const JSONNODE * node){
363 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_as_bool"),
return false;);
364 return ((JSONNode*)node) -> as_bool();
369 JSONNODE * json_as_node(json_const JSONNODE * node){
370 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_as_node"),
return 0;);
371 return MANAGER_INSERT(JSONNode::newJSONNode_Shallow(((JSONNode*)node) -> as_node()));
374 JSONNODE * json_as_array(json_const JSONNODE * node){
375 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_as_array"),
return 0;);
376 return MANAGER_INSERT(JSONNode::newJSONNode_Shallow(((JSONNode*)node) -> as_array()));
380 #if defined(JSON_BINARY) || defined(JSON_EXPOSE_BASE64)
381 static void * returnDecode64(
const std::string & result,
unsigned long * size) json_nothrow json_cold;
382 static void * returnDecode64(
const std::string & result,
unsigned long * size) json_nothrow {
383 const size_t len = result.length();
384 if (json_likely(size)) *size = (json_index_t)len;
386 if (json_unlikely(result.empty()))
return 0;
388 #ifdef JSON_MEMORY_MANAGE
389 return json_global(STRING_HANDLER).insert(std::memcpy(json_malloc<char>(len), result.data(), len));
391 return std::memcpy(json_malloc<char>(len), result.data(), len);
397 void * json_as_binary(json_const JSONNODE * node,
unsigned long * size){
398 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_as_binary"),
if (size){*size = 0;}
return 0;);
399 return returnDecode64(((JSONNode*)node) -> as_binary(), size);
404 #ifdef JSON_EXPOSE_BASE64
405 #include "JSON_Base64.h"
406 json_char * json_encode64(json_const
void * binary, json_index_t bytes){
407 const json_string result(JSONBase64::json_encode64((
const unsigned char *)binary, (
size_t)bytes));
408 #ifdef JSON_MEMORY_MANAGE
409 return (json_char*)json_global(STRING_HANDLER).insert((json_char*)std::memcpy(json_malloc<json_char>(result.length() + 1), result.c_str(), (result.length() + 1) *
sizeof(json_char)));
411 return (json_char*)std::memcpy(json_malloc<json_char>(result.length() + 1), result.c_str(), (result.length() + 1) *
sizeof(json_char));
415 void * json_decode64(
const json_char * text,
unsigned long * size){
416 return returnDecode64(JSONBase64::json_decode64(text), size);
420 #ifdef JSON_WRITE_PRIORITY
421 json_char * json_write(json_const JSONNODE * node){
422 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_write"),
return toCString(EMPTY_CSTRING););
423 return toCString(((JSONNode*)node) -> write());
426 json_char * json_write_formatted(json_const JSONNODE * node){
427 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_write_formatted"),
return toCString(EMPTY_CSTRING););
428 return toCString(((JSONNode*)node) -> write_formatted());
433 void json_set_name(JSONNODE * node, json_const json_char * name){
434 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_set_name"),
return;);
435 JSON_ASSERT_SAFE(name, JSON_TEXT(
"null name to json_set_name"), name = EMPTY_CSTRING;);
436 ((JSONNode*)node) -> set_name(TOCONST_CSTR(name));
440 void json_set_comment(JSONNODE * node, json_const json_char * comment){
441 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_set_comment"),
return;);
442 JSON_ASSERT_SAFE(comment, JSON_TEXT(
"null name to json_set_comment"), comment = EMPTY_CSTRING;);
443 ((JSONNode*)node) -> set_comment(TOCONST_CSTR(comment));
447 void json_clear(JSONNODE * node){
448 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_clear"),
return;);
449 ((JSONNode*)node) -> clear();
452 void json_nullify(JSONNODE * node){
453 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_nullify"),
return;);
454 ((JSONNode*)node) -> nullify();
457 void json_swap(JSONNODE * node, JSONNODE * node2){
458 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_swap"),
return;);
459 JSON_ASSERT_SAFE(node2, JSON_TEXT(
"null node to json_swap"),
return;);
460 ((JSONNode*)node) -> swap(*(JSONNode*)node2);
463 void json_merge(JSONNODE * node, JSONNODE * node2){
464 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_merge"),
return;);
465 JSON_ASSERT_SAFE(node2, JSON_TEXT(
"null node to json_merge"),
return;);
466 ((JSONNode*)node) -> merge(*(JSONNode*)node2);
469 #if !defined(JSON_PREPARSE) && defined(JSON_READ_PRIORITY)
470 void json_preparse(JSONNODE * node){
471 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_preparse"),
return;);
472 ((JSONNode*)node) -> preparse();
477 void json_set_binary(JSONNODE * node, json_const
void * data,
unsigned long length){
478 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_swap"),
return;);
479 JSON_ASSERT_SAFE(data, JSON_TEXT(
"null data to json_set_binary"), *((JSONNode*)node) = EMPTY_CSTRING;
return;);
480 ((JSONNode*)node) -> set_binary((
unsigned char *)data, (
size_t)length);
485 void json_cast(JSONNODE * node,
char type){
486 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_cast"),
return;);
487 ((JSONNode*)node) -> cast(type);
492 void json_reserve(JSONNODE * node, json_index_t siz){
493 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_reserve"),
return;);
494 ((JSONNode*)node) -> reserve(siz);
497 JSONNODE * json_at(JSONNODE * node,
unsigned int pos){
498 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_at"),
return 0;);
500 return &((JSONNode*)node) -> at(pos);
501 } json_catch (std::out_of_range, (
void)0; )
502 #ifndef JSON_NO_EXCEPTIONS
507 JSONNODE * json_get(JSONNODE * node, json_const json_char * name){
508 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_get"),
return 0;);
509 JSON_ASSERT_SAFE(name, JSON_TEXT(
"null node to json_get. Did you mean to use json_at?"),
return 0;);
511 return &((JSONNode*)node) -> at(TOCONST_CSTR(name));
512 } json_catch (std::out_of_range, (
void)0; )
513 #ifndef JSON_NO_EXCEPTIONS
519 #ifdef JSON_CASE_INSENSITIVE_FUNCTIONS
520 JSONNODE * json_get_nocase(JSONNODE * node, json_const json_char * name){
521 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_at_nocase"),
return 0;);
522 JSON_ASSERT_SAFE(name, JSON_TEXT(
"null name to json_at_nocase"),
return 0;);
524 return &((JSONNode*)node) -> at_nocase(TOCONST_CSTR(name));
525 } json_catch (std::out_of_range, (
void)0; )
526 #ifndef JSON_NO_EXCEPTIONS
531 JSONNODE * json_pop_back_nocase(JSONNODE * node, json_const json_char * name){
532 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_pop_back_nocase"),
return 0;);
533 JSON_ASSERT_SAFE(name, JSON_TEXT(
"null name to json_pop_back_nocase"),
return 0;);
534 return MANAGER_INSERT(((JSONNode*)node) -> pop_back_nocase(TOCONST_CSTR(name)));
538 void json_push_back(JSONNODE * node, JSONNODE * node2){
539 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_push_back"),
return;);
540 JSON_ASSERT_SAFE(node2, JSON_TEXT(
"null node2 to json_push_back"),
return;);
541 #ifdef JSON_MEMORY_MANAGE
542 json_global(NODE_HANDLER).remove(node2);
544 ((JSONNode*)node) -> push_back((JSONNode*)node2);
547 JSONNODE * json_pop_back_at(JSONNODE * node,
unsigned int pos){
548 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_pop_back_i"),
return 0;);
549 return MANAGER_INSERT(((JSONNode*)node) -> pop_back(pos));
552 JSONNODE * json_pop_back(JSONNODE * node, json_const json_char * name){
553 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_pop_back"),
return 0;);
554 JSON_ASSERT_SAFE(name, JSON_TEXT(
"null name to json_pop_back. Did you mean to use json_pop_back_at?"),
return 0;);
555 return MANAGER_INSERT(((JSONNode*)node) -> pop_back(TOCONST_CSTR(name)));
558 #ifdef JSON_ITERATORS
559 JSONNODE_ITERATOR json_find(JSONNODE * node, json_const json_char * name){
560 return (JSONNODE_ITERATOR)(((JSONNode*)node) -> find(TOCONST_CSTR(name)));
563 #ifdef JSON_CASE_INSENSITIVE_FUNCTIONS
564 JSONNODE_ITERATOR json_find_nocase(JSONNODE * node, json_const json_char * name){
565 return (JSONNODE_ITERATOR)(((JSONNode*)node) -> find_nocase(TOCONST_CSTR(name)));
569 JSONNODE_ITERATOR json_erase(JSONNODE * node, JSONNODE_ITERATOR it){
570 return (JSONNODE_ITERATOR)(((JSONNode*)node) -> erase((JSONNode**)it));
573 JSONNODE_ITERATOR json_erase_multi(JSONNODE * node, JSONNODE_ITERATOR start, JSONNODE_ITERATOR end){
574 return (JSONNODE_ITERATOR)(((JSONNode*)node) -> erase((JSONNode**)start, (JSONNode**)end));
577 JSONNODE_ITERATOR json_insert(JSONNODE * node, JSONNODE_ITERATOR it, JSONNODE * node2){
578 #ifdef JSON_MEMORY_MANAGE
579 json_global(NODE_HANDLER).remove(node2);
581 return (JSONNODE_ITERATOR)(((JSONNode*)node) -> insert((JSONNode**)it, (JSONNode*)node2));
584 JSONNODE_ITERATOR json_insert_multi(JSONNODE * node, JSONNODE_ITERATOR it, JSONNODE_ITERATOR start, JSONNODE_ITERATOR end){
585 return (JSONNODE_ITERATOR)(((JSONNode*)node) -> insert((JSONNode**)it, (JSONNode**)start, (JSONNode**)end));
589 JSONNODE_ITERATOR json_begin(JSONNODE * node){
590 return (JSONNODE_ITERATOR)(((JSONNode*)node) -> begin());
593 JSONNODE_ITERATOR json_end(JSONNODE * node){
594 return (JSONNODE_ITERATOR)(((JSONNode*)node) -> end());
599 json_bool_t json_equal(JSONNODE * node, JSONNODE * node2){
600 JSON_ASSERT_SAFE(node, JSON_TEXT(
"null node to json_equal"),
return false;);
601 JSON_ASSERT_SAFE(node2, JSON_TEXT(
"null node2 to json_equal"),
return false;);
602 return (json_bool_t)(*((JSONNode*)node) == *((JSONNode*)node2));
605 #endif //JSON_LIBRARY