29 printf(
"we have parsed too far");
37 if (!buffer)
return NULL;
38 if (buffer[0] == target)
return buffer;
39 while ((buffer[0] !=
'\0')&&(buffer[1] !=
'\0'))
41 if ((buffer[0] !=
'\\')&&(buffer[1] == target))
56 if (!parse)
return NULL;
83 if (p2 != NULL)p =
MIN(p,p2);
88 if (p3 != NULL)p1 =
MIN(p1,p3);
93 if (p1 != NULL)p =
MIN(p,p1);
106 sj_set_error(
"sj_parse_string: string is a zero or negative length");
119 if (strncmp(parse->
position,
"null",4)==0)
138 if (
string == NULL)
return NULL;
146 if (!parse)
return NULL;
150 sj_set_error(
"sj_parse_object: expected first character to be a {\n");
156 if (!json)
return NULL;
165 sj_set_error(
"--=== array value failed to parse! ===--\n");
187 if (!parse)
return NULL;
191 sj_set_error(
"sj_parse_object: expected first character to be a {\n");
197 if (!json)
return NULL;
206 sj_set_error(
"sj_parse_object: no colon (:) delimeter for object\n");
216 sj_set_error(
"--=== array value failed to parse! ===--");
244 parse.
position = strchr(
string,
'{');
245 parse.
end = &
string[length -1];
char * get_next_unescaped_char(char *buffer, char target)
this is the abstract container structure for all json data This structure may be an object...
SJson * sj_parse_object(jsParse *parse)
void sj_object_insert(SJson *object, char *key, SJson *value)
insert data into a json object
void sj_string_set_limit(SJString *string, char *s, unsigned long l)
set the value of string to s but only length of s
void sj_array_append(SJson *array, SJson *value)
append to a JSON array a new value
int overseek_check_fail(jsParse *parse)
SJson * sj_object_new()
allocate a new empty json object
SJson * sj_parse_value(jsParse *parse)
SJString * sj_string_new()
make a new empty string
SJson * sj_parse_array(jsParse *parse)
SJson * sj_parse_buffer(char *string, unsigned long length)
given a string, create a JSON object from it
SJson * sj_null_new()
make a new json value that is NULL
SJString * sj_parse_string(jsParse *parse)
SJson * sj_string_to_value(SJString *string)
make a jason value object out of a string
void sj_set_error(char *er)
used internally to se the error message
void sj_array_free(SJson *array)
a basic structure that keeps track of a string and its length Automatically grows to accomodate longe...
void sj_object_free(SJson *object)
free a previously allocated json object
SJson * sj_array_new()
allocate a new empty json array
void sj_string_free(SJString *string)
free an SJString
structure keeps track of the buffer being parsed and the position last used