{"id":16239822,"url":"https://github.com/nopnop2002/esp-idf-json","last_synced_at":"2025-07-22T17:02:58.245Z","repository":{"id":37401049,"uuid":"230612991","full_name":"nopnop2002/esp-idf-json","owner":"nopnop2002","description":" Example of JSON Serialize and Deserialize in ESP-IDF","archived":false,"fork":false,"pushed_at":"2025-06-30T00:16:54.000Z","size":201,"stargazers_count":106,"open_issues_count":0,"forks_count":21,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-30T01:25:54.808Z","etag":null,"topics":["deserialize","esp-idf","esp32","json","serializer"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nopnop2002.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-12-28T13:22:09.000Z","updated_at":"2025-06-30T00:16:57.000Z","dependencies_parsed_at":"2023-12-21T04:24:07.968Z","dependency_job_id":"4d85c9a1-50b3-49cf-bc2b-7998dce39797","html_url":"https://github.com/nopnop2002/esp-idf-json","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nopnop2002/esp-idf-json","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nopnop2002%2Fesp-idf-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nopnop2002%2Fesp-idf-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nopnop2002%2Fesp-idf-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nopnop2002%2Fesp-idf-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nopnop2002","download_url":"https://codeload.github.com/nopnop2002/esp-idf-json/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nopnop2002%2Fesp-idf-json/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266535676,"owners_count":23944274,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deserialize","esp-idf","esp32","json","serializer"],"created_at":"2024-10-10T13:45:16.674Z","updated_at":"2025-07-22T17:02:58.216Z","avatar_url":"https://github.com/nopnop2002.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# esp-idf-json\nExample of JSON Serialize and Deserialize with ESP-IDF.\n\n\nESP-IDF includes [this](https://github.com/DaveGamble/cJSON) cJSON library.   \nYou can use JSON components as standard.   \nBut the documentation is very poor.   \nThe official documentation for the JSON component is [here](https://github.com/espressif/esp-idf/tree/master/components/json/README).\n\n[Here](https://github.com/DaveGamble/cJSON/blob/master/tests/readme_examples.c) is a example by Dave Gamble.\n\n# How to use\n```\ngit clone https://github.com/nopnop2002/esp-idf-json\ncd esp-idf-json/json-basic-object\nidf.py flash monitor\n```\n\n# About cJSON_Print\nFrom print_value() function, the pointer returned is allocated by cJSON_strdup()  and it is returned to the caller.   \nBuffers returned by cJSON_Print must be freed by the caller.   \nPlease use the proper API (cJSON_free) rather than directly calling stdlib free.   \n\n```\nchar *my_json_string = cJSON_Print(root);\nESP_LOGI(TAG, \"my_json_string\\n%s\",my_json_string);\ncJSON_Delete(root);\ncJSON_free(my_json_string);\n```\n\n\n# Basic Structure   \n- Array   \n\tArray, like this, have no name.    \n\tArray starts with [ and ends with ].   \n\troot is defined by cJSON_CreateArray.   \n\telement is added by cJSON_AddItemToArray.   \n\t```\n\t[\"abc\", 123, true, false, null]\n\t```\n\n- Object   \n\tObject, like this, have name.   \n\tObject starts with { and ends with }.   \n\troot is defined by cJSON_CreateObject.   \n\telement is added by cJSON_AddItemToObject.   \n\t```\n\t{\n\t        \"version\":      \"v5.0-dev-3202-ga2d5041492-dirty\",\n\t        \"cores\":        2,\n\t}\n\t```\n\n# Complex structure   \n\n- Object in Array   \n\t```\n\t[\"abc\", 123, true, false, null, {\n\t                \"version\":      \"v5.0-dev-3202-ga2d5041492-dirty\",\n\t                \"cores\":        2\n\t        }]\n\t```\n\n\t```\n\t[{\n\t                \"id\":   0,\n\t                \"version\":      \"v5.0-dev-3202-ga2d5041492-dirty\",\n\t                \"cores\":        2\n\t        }, {\n\t                \"id\":   1,\n\t                \"version\":      \"v5.0-dev-3202-ga2d5041492-dirty\",\n\t                \"cores\":        2\n\t        }]\n\t```\n\n- Array in Array   \n\t```\n\t[[\"abc\", 120], [\"abc\", 121], [\"abc\", 122], [\"abc\", 123], [\"abc\", 124], [\"abc\", 125], [\"abc\", 126], [\"abc\", 127], [\"abc\", 128], [\"abc\", 129]]\n\t```\n\n\n\n- Object in Object   \n\t```\n\t{\n\t        \"name\": \"Jack (\\\"Bee\\\") Nimble\",\n\t        \"format\":       {\n\t                \"type\": \"rect\",\n\t                \"width\":        1920,\n\t                \"height\":       1080,\n\t                \"interlace\":    false,\n\t                \"frame rate\":   24\n\t        }\n\t}\n\t```\n\n- Array in Object   \n\t```\n\t{\n\t        \"version\":      \"v5.0-dev-3202-ga2d5041492-dirty\",\n\t        \"cores\":        2,\n\t        \"array\":        [\"abc\", 123, true, false, null]\n\t}\n\t```\n\n# More Complex structure   \n\n- Object in Array in Object   \n\t```\n\t{\n\t        \"version\":      \"v5.0-dev-3202-ga2d5041492-dirty\",\n\t        \"cores\":        2,\n\t        \"array\":  [{\n\t                        \"width\":        1280,\n\t                        \"height\":       720\n\t                }, {\n\t                        \"width\":        1920,\n\t                        \"height\":       1080\n\t                }, {\n\t                        \"width\":        3840,\n\t                        \"height\":       2160\n\t                }]\n\t}\n\t```\n\n- Array in Object in Array   \n\t```\n\t[{\n\t                \"id\":   0,\n\t                \"version\":      \"v5.0-dev-3202-ga2d5041492-dirty\",\n\t                \"cores\":        2,\n\t                \"array\":        [\"abc\", 123, true, false, null]\n\t        }, {\n\t                \"id\":   1,\n\t                \"version\":      \"v5.0-dev-3202-ga2d5041492-dirty\",\n\t                \"cores\":        2,\n\t                \"array\":        [\"abc\", 123, true, false, null]\n\t        }]\n\t```\n\n# How to Serialize   \nSerialization starts from the lowest level.   \nNo matter how complex the structure, there are only objects and arrays.   \n\n- Target structure\n\t```\n\t{\n\t        \"version\":      \"v5.0-dev-3202-ga2d5041492-dirty\",\n\t        \"cores\":        2,\n\t        \"array\":  [{\n\t                        \"width\":        1280,\n\t                        \"height\":       720\n\t                }, {\n\t                        \"width\":        1920,\n\t                        \"height\":       1080\n\t                }, {\n\t                        \"width\":        3840,\n\t                        \"height\":       2160\n\t                }]\n\t}\n\t```\n\n\n\t- Create 3 objects   \n\t\tThis is simple object.\n\t\t```\n\t\t                {\n\t\t                        \"width\":        1280,\n\t\t                        \"height\":       720\n\t\t                }\n\t\t```\n\t\t```\n\t\t                {\n\t\t                        \"width\":        1920,\n\t\t                        \"height\":       1080\n\t\t                }\n\t\t```\n\t\t```\n\t\t                {\n\t\t                        \"width\":        3840,\n\t\t                        \"height\":       2160\n\t\t                }\n\n\t\t```\n\n\t- Create array   \n\t\tThis is object in array.\n\t\t```\n\t\t               [{\n\t\t                        \"width\":        1280,\n\t\t                        \"height\":       720\n\t\t                }, {\n\t\t                        \"width\":        1920,\n\t\t                        \"height\":       1080\n\t\t                }, {\n\t\t                        \"width\":        3840,\n\t\t                        \"height\":       2160\n\t\t                }]\n\t\t```\n\n\t- Create object as root   \n\t\tThis is array in object.\n\t\t```\n\t\t{\n\t\t        \"version\":      \"v5.0-dev-3202-ga2d5041492-dirty\",\n\t\t        \"cores\":        2,\n\t\t        \"array\":  [{\n\t\t                        \"width\":        1280,\n\t\t                        \"height\":       720\n\t\t                }, {\n\t\t                        \"width\":        1920,\n\t\t                        \"height\":       1080\n\t\t                }, {\n\t\t                        \"width\":        3840,\n\t\t                        \"height\":       2160\n\t\t                }]\n\t\t}\n\t\t```\n\n\n- Target structure\n\t```\n\t[{\n\t                \"id\":   0,\n\t                \"version\":      \"v5.0-dev-3202-ga2d5041492-dirty\",\n\t                \"cores\":        2,\n\t                \"array\":        [\"abc\", 123, true, false, null]\n\t        }, {\n\t                \"id\":   1,\n\t                \"version\":      \"v5.0-dev-3202-ga2d5041492-dirty\",\n\t                \"cores\":        2,\n\t                \"array\":        [\"abc\", 123, true, false, null]\n\t        }]\n\t```\n\n\n\t- Create 2 arrays   \n\t\tThis is simple array.\n\t\t```\n\t\t[\"abc\", 123, true, false, null]\n\t\t```\n\t\t```\n\t\t[\"abc\", 123, true, false, null]\n\t\t```\n\n\t- Create 2 objects   \n\t\tThis is array in object.\n\t\t```\n\t\t        {\n\t\t                \"id\":   1,\n\t\t                \"version\":      \"v5.0-dev-3202-ga2d5041492-dirty\",\n\t\t                \"cores\":        2,\n\t\t                \"array\":        [\"abc\", 123, true, false, null]\n\t\t        }\n\t\t```\n\n\t\t```\n\t\t        {\n\t\t                \"id\":   0,\n\t\t                \"version\":      \"v5.0-dev-3202-ga2d5041492-dirty\",\n\t\t                \"cores\":        2,\n\t\t                \"array\":        [\"abc\", 123, true, false, null]\n\t\t        }\n\t\t```\n\n\t- Create array as root   \n\t\tThis is object in array.\n\t\t```\n\t\t[{\n\t\t                \"id\":   0,\n\t\t                \"version\":      \"v5.0-dev-3202-ga2d5041492-dirty\",\n\t\t                \"cores\":        2,\n\t\t                \"array\":        [\"abc\", 123, true, false, null]\n\t\t        }, {\n\t\t                \"id\":   1,\n\t\t                \"version\":      \"v5.0-dev-3202-ga2d5041492-dirty\",\n\t\t                \"cores\":        2,\n\t\t                \"array\":        [\"abc\", 123, true, false, null]\n\t\t        }]\n\t\t```\n\n\n\n# JSON Data Set Sample\nThis is a sample JSON data set.   \nhttps://opensource.adobe.com/Spry/samples/data_region/JSONDataSetSample.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnopnop2002%2Fesp-idf-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnopnop2002%2Fesp-idf-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnopnop2002%2Fesp-idf-json/lists"}