cJSON project to achieve general process

CJSON code analysis:
JSON is a lightweight data-interchange format, its role is the data of other formats,
processed into JSON format, JSON-formatted data easy to read and to write. CJSON, is to use C language to implement JSON
1, starting from the main function, it can be seen inside the most important function is to doit () function,
the main function main () function is to achieve this by calling the function. But using doit function
when the function of the realization, before calling the doit (), must be given within the main function to be processed
string (string array), and then to doit () function name can be passed in an array of characters . If you do not
give the string to be processed inside the main function, but to deal with JSON data in an external file of the main function,
when you call dofile () function, the function is called, just give the function to process incoming data file the path
and file name (the path for the current to test.c file path processing data files), dofile () internal function
also calls doit () function to implement process and print data. create_objects () function is some data
example of processing. When actual processing external file function less than create_objects ().
2, doit (analytic) function. Internal doit () function call is cJSON_Parse () function, cJSON_Print () function,
cJSON_Delete () function; when you call cJSON_Parse () function, passing the name of the array parameter is an array of characters,
when calling cJSON_Print () function incoming is cJSON_Parse () return value of the function, calling cJSON_Delete () function
When incoming is cJSON_Parse () return value of the function. cJSON_Parse () function returns the incoming data analysis processing, as the processing
JSON format. action cJSON_Parse () function is a printing cJSON_Parse () function after the data is processed. cJSON_Delete () function
role is to release the memory occupied.
3, parsing cJSON_Parse () function. cJSON_Parse () function is passed the parameter string array inside the array name (value) on the call
cJSON_ParseWithOpts () a function (mode of the call is a return values).
4, cJSON_ParseWithOpts () function, parameter passing as cJSON_ParseWithOpts (value, 0,0) when calling. () cJSON_ParseWithOpts function
inside the main call cJSON_New_Item () function, parse_value () function. cJSON_New_Item () function is used to create a new project,
parse_value () function is used to parse the project. Focus is parse_value () function.
5, parse_value () function to parse the string, arrays, objects, null, false, true, 6 Species Data item type.

Note: The above are my interpretation, there may be some omissions and deviations, please suddenly spray, then I will explain this project continue to be updated.

Published 20 original articles · won praise 11 · views 3671

Guess you like

Origin blog.csdn.net/m0_46204326/article/details/104351370