MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / parse_object

Function parse_object

outofcore/src/cJSON.cpp:394–427  ·  view source on GitHub ↗

Build an object from the text. */

Source from the content-addressed store, hash-verified

392
393/* Build an object from the text. */
394static const char *parse_object(cJSON *item,const char *value)
395{
396 cJSON *child;
397 if (*value!='{') {ep=value;return nullptr;} /* not an object! */
398
399 item->type=cJSON_Object;
400 value=skip(value+1);
401 if (*value=='}') return value+1; /* empty array. */
402
403 item->child=child=cJSON_New_Item();
404 if (!item->child) return nullptr;
405 value=skip(parse_string(child,skip(value)));
406 if (!value) return nullptr;
407 child->string=child->valuestring;child->valuestring=nullptr;
408 if (*value!=':') {ep=value;return nullptr;} /* fail! */
409 value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */
410 if (!value) return nullptr;
411
412 while (*value==',')
413 {
414 cJSON *new_item;
415 if (!(new_item=cJSON_New_Item())) return nullptr; /* memory fail */
416 child->next=new_item;new_item->prev=child;child=new_item;
417 value=skip(parse_string(child,skip(value+1)));
418 if (!value) return nullptr;
419 child->string=child->valuestring;child->valuestring=nullptr;
420 if (*value!=':') {ep=value;return nullptr;} /* fail! */
421 value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */
422 if (!value) return nullptr;
423 }
424
425 if (*value=='}') return value+1; /* end of array */
426 ep=value;return nullptr; /* malformed. */
427}
428
429/* Render an object to text. */
430static char *print_object(cJSON *item,int depth,int fmt)

Callers 1

parse_valueFunction · 0.85

Calls 4

skipFunction · 0.85
cJSON_New_ItemFunction · 0.85
parse_stringFunction · 0.85
parse_valueFunction · 0.85

Tested by

no test coverage detected