{"id":13805146,"url":"https://github.com/SergiuToporjinschi/settingsmanager","last_synced_at":"2025-05-13T18:33:17.542Z","repository":{"id":138043462,"uuid":"161241224","full_name":"SergiuToporjinschi/settingsmanager","owner":"SergiuToporjinschi","description":"Saving, reading and changing settings from Json file on SPIFFS","archived":false,"fork":false,"pushed_at":"2024-08-05T14:32:47.000Z","size":123,"stargazers_count":18,"open_issues_count":6,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-14T14:58:51.661Z","etag":null,"topics":["arduino","deserialization","esp8266","file","json","serialization","spiffs"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SergiuToporjinschi.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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-12-10T21:53:34.000Z","updated_at":"2024-05-17T01:42:13.000Z","dependencies_parsed_at":"2025-04-16T01:15:44.649Z","dependency_job_id":null,"html_url":"https://github.com/SergiuToporjinschi/settingsmanager","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SergiuToporjinschi%2Fsettingsmanager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SergiuToporjinschi%2Fsettingsmanager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SergiuToporjinschi%2Fsettingsmanager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SergiuToporjinschi%2Fsettingsmanager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SergiuToporjinschi","download_url":"https://codeload.github.com/SergiuToporjinschi/settingsmanager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254003506,"owners_count":21997897,"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","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":["arduino","deserialization","esp8266","file","json","serialization","spiffs"],"created_at":"2024-08-04T01:00:57.977Z","updated_at":"2025-05-13T18:33:17.186Z","avatar_url":"https://github.com/SergiuToporjinschi.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"[![GitHub repo size in bytes](https://img.shields.io/github/repo-size/badges/shields.svg)](https://github.com/SergiuToporjinschi/settingsmanager)\n[![GitHub last commit](https://img.shields.io/github/last-commit/SergiuToporjinschi/settingsmanager.svg)](https://github.com/SergiuToporjinschi/settingsmanager/commits/master)\n[![GitHub stars](https://img.shields.io/github/stars/SergiuToporjinschi/settingsmanager.svg)](https://github.com/SergiuToporjinschi/settingsmanager/stargazers)\n[![GitHub watchers](https://img.shields.io/github/watchers/SergiuToporjinschi/settingsmanager.svg)](https://github.com/SergiuToporjinschi/settingsmanager/watchers)\n[![GitHub license](https://img.shields.io/github/license/SergiuToporjinschi/settingsmanager.svg)](https://github.com/SergiuToporjinschi/settingsmanager/blob/master/LICENSE)\n[![Code Climate](https://codeclimate.com/github/codeclimate/codeclimate/badges/gpa.svg)](https://codeclimate.com/github/SergiuToporjinschi/settingsmanager)\n[![Build Status](https://travis-ci.org/SergiuToporjinschi/settingsmanager.svg?branch=master)](https://travis-ci.org/SergiuToporjinschi/settingsmanager)\n\n# Settings Manager\n\nIntarface for reading, writing and managing settings in JSON format on SPIFFS.\n# Dependency \n- [ArduinoJson V6](https://arduinojson.org/v6/api/jsonobject/)\n# Compile macros\n\n# Settings file\n```json\n{\n \"esp\" : {\n\t\"delayTime\": 300\n },\n \"wlan\": {\n\t\"hostName\": \"hostName of esp\",\n\t\"ssid\": \"network sidd \",\n\t\"password\": \"network password\"\n },\n \"mqtt\": {\n\t\"clientId\": \"mqttClientid\",\n\t\"server\": \"127.0.0.1\",\n\t\"port\": \"9999\",\n\t\"user\": \"mqttUser\",\n\t\"password\": \"mqttPassword\",\n\t\"status\": {\n\t\t\"topic\": \"topic/for/status\"\n\t},\n\t\"internalTopics\" : {\n\t\t\"settings\": \"Settings/topic\",\n\t\t\"cmd\": \"cmd/topic\"\n\t}\n },\n \"ledPin\":13,\n \"sketchVersion\":\"1.0\",\n \"updateServer\":\"http://testUpdateServer.com\",\n \"process\": {\n\t\"topic\": \"other/topic\",\n\t\"interval\": 1000\n }\n}\n```\n\n# Syntax\nFor getting value o a key you can call ``` sm.getInt(\u003cpath/key\u003e[, defaultValue]) ``` The default value will be returned if the ```path/key``` has not been found.\n\nFor changing value of a key ``` sm.setInt(\u003cpath/key\u003e, \u003cvalue\u003e) ``` will return SM_SUCCESS if the key has been found and changed; SM_KEY_NOT_FOUND if the key has not been found;\n\nSee [SettingsManager.h](https://github.com/SergiuToporjinschi/settingsmanager/blob/master/src/SettingsManager.h) for more information.\n\n# Examples\nReading/loading settings from file;\n```Cpp\n#include \"SettingsManager.h\"\n\nSettingsManager sm; //Initialize\n\nvoid setup() {\n    Serial.begin(115200);\n    sm.readSettings(\"/config.json\"); //Loading json from file config.json\n}\n\nvoid loop(){\n    Serial.println(\"int ledPin: \"); \n    Serial.print(sm.getInt(\"ledPin\", 99)); //get the int value from json root\n    Serial.println(\"Test getJsonVariant\");\n    \n    JsonObject vr = sm.getJsonVariant(\"mqtt.status\");\n    if (!vr.isNull()) {\n        serializeJsonPretty(vr, Serial);\n        Serial.println(\"\");\n    } else {\n        Serial.println(\"no variant\");\n    }\n}\n```\n\nLoading json from a string\n```Cpp\n#include \"SettingsManager.h\"\n\nSettingsManager sm; //Initialize\n\nvoid setup() {\n    Serial.begin(115200);\n    sm.readSettings(\"/config.json\"); //Loading json from file config.json\n}\n\nvoid loop(){\n    sm.loadJson(\"{\\\"testInLoadingJson\\\":\\\"this is a string value\\\",\\\"Level1\\\":{\\\"Level2Key\\\":12,\\\"Level2Test\\\":true,\\\"Level3\\\":{\\\"float\\\":23.5}}}\");\n    JsonObject ob = sm.getRoot();\n    if (!ob.isNull()) {\n        serializeJsonPretty(ob, Serial);\n        Serial.println(\"\");\n    } else {\n        Serial.println(\"loadSetti: no ob\");\n    }\n}\n```\n\nChange value of a key\n```Cpp\n#include \"SettingsManager.h\"\n\nSettingsManager sm; //Initialize\n\nvoid setup() {\n    Serial.begin(115200);\n    sm.readSettings(\"/config.json\"); //Loading json from file config.json\n}\n\nvoid loop(){\n    int res = sm.setString(\"updateServer\", \"Other Test\");\n    sm.setInt(\"ledPin\", 15);\n    sm.writeSettings(\"/config.json\");\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSergiuToporjinschi%2Fsettingsmanager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSergiuToporjinschi%2Fsettingsmanager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSergiuToporjinschi%2Fsettingsmanager/lists"}