JSON libraries HelloWorld by neudeep - November 22, 2019November 22, 20190 JSON libraries 1.frozen Output JSON objects in C as JSON formatted strings and parse JSON formatted strings back into the C presentation of the JSON objects. FEATUES: • C and C++ complaint portable. • Several extra format specifiers supported. JSON token: This stucture contains- Pointer pointing to beginning of the value. Value length Type of the token Token types are string,number,true,false,null, object start, object end,array start and array end. API’s: • json_scanf Scans json string directly into c/c++ variables. • json_printf Print c/c++ variables directly into output stream. • json_setf Modifies existing json_string. • json_fread Reads json from a file. • json_fprintf Writes json to a file. • json_scanf_array_elem Scan array element with given path and index • json_printf_array prints contiguous C arrays. References:https://github.com/cesanta/frozen SIZE of object file is 42 kBytes. 2.JSMN Minimalistic JSON parser in C. FEATURES: Compatible with C89 Single head library easily integrated into resource limited or emb projects API contains only 2 functions. JSON token: This structure contains- type start position in JSON data string end position in JSON data string size Token types are-object,array,string, primitive(number/boolean/true-false/null) API’s: • jsmn_init Create JSON parser over array of tokens. • jsmn_parse Parses JSON data string into array of tokens, each describing JSON object. References:https://github.com/zserge/jsmn SIZE of object file is upto 26 kBytes. 3.JSON-C JSON-C implements referrence counting object that allows you to easily construct JSON objects in c, output them as JSON formatted strings and parse JSON formatted strings back into c representation of JSON objects. FEATURES: JSON token: Token types are boolean,double,int,object,array,string. API’s: • json_object_to_json_string Stringify object to JSON format grabbing the shared ownership of object. • json_object_get Increament reference count of json_object. • json_object_put Decrement reference count of json_object,and free it if reaches to zero. • json_object_userdata_to_json_string Copy the userdata string to over the destination buffer. • json_object_new_array Create a new empty json_object of type json_type_array. • json_object_get_array Get the arraylist of json_object of type json_type_array. • json_object_array_add Add an element to the end of json_object of type json_type_array. • json_obect_array_put_idx Insert or replace an element at a specified index of the array. • json_object_array_get_idx Get the element at specifies index of the array. All these functions for array are also defined for following json_types- boolean,double,int,int64,object . References:https://github.com/json-c/json-c SIZE of object file is upto 300 kBytes. Contents Share this:Click to share on Twitter (Opens in new window)Click to share on Facebook (Opens in new window)MoreClick to share on LinkedIn (Opens in new window)Click to share on WhatsApp (Opens in new window)Click to email a link to a friend (Opens in new window)Like this:Like Loading... Related