MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / cJSON_ParseWithOpts

Function cJSON_ParseWithOpts

lib/cJSON.c:886–923  ·  view source on GitHub ↗

Parse an object - create a new root, and populate. */

Source from the content-addressed store, hash-verified

884
885/* Parse an object - create a new root, and populate. */
886cJSON *cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cjbool require_null_terminated)
887{
888 const unsigned char *end = NULL;
889 /* use global error pointer if no specific one was given */
890 const unsigned char **ep = return_parse_end ? (const unsigned char**)return_parse_end : &global_ep;
891 cJSON *c = cJSON_New_Item();
892 *ep = NULL;
893 if (!c) /* memory fail */
894 {
895 return NULL;
896 }
897
898 end = parse_value(c, skip((const unsigned char*)value), ep);
899 if (!end)
900 {
901 /* parse failure. ep is set. */
902 cJSON_Delete(c);
903 return NULL;
904 }
905
906 /* if we require null-terminated JSON without appended garbage, skip and then check for a null terminator */
907 if (require_null_terminated)
908 {
909 end = skip(end);
910 if (*end)
911 {
912 cJSON_Delete(c);
913 *ep = end;
914 return NULL;
915 }
916 }
917 if (return_parse_end)
918 {
919 *return_parse_end = (const char*)end;
920 }
921
922 return c;
923}
924
925/* Default options for cJSON_Parse */
926cJSON *cJSON_Parse(const char *value)

Callers 4

parse_mi_requestFunction · 0.85
handle_reply_jsonrpcFunction · 0.85
janus_brief_parse_msgFunction · 0.85
cJSON_ParseFunction · 0.85

Calls 4

cJSON_New_ItemFunction · 0.70
parse_valueFunction · 0.70
skipFunction · 0.70
cJSON_DeleteFunction · 0.70

Tested by

no test coverage detected