{"id":13498292,"url":"https://github.com/MohdShamweel/JsonToForms","last_synced_at":"2025-03-29T00:34:11.171Z","repository":{"id":217949992,"uuid":"224117222","full_name":"MohdShamweel/JsonToForms","owner":"MohdShamweel","description":"A simple library which uses JSON to build forms : JSON Form Builder","archived":false,"fork":false,"pushed_at":"2021-01-26T04:14:25.000Z","size":196,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-31T15:38:29.740Z","etag":null,"topics":["android","dynamic-form","form-builder","forms","json-forms"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MohdShamweel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2019-11-26T06:19:15.000Z","updated_at":"2024-01-03T03:27:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"5486b101-437b-42c0-94f1-6a7aca8bf3c2","html_url":"https://github.com/MohdShamweel/JsonToForms","commit_stats":null,"previous_names":["mohdshamweel/jsontoforms"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MohdShamweel%2FJsonToForms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MohdShamweel%2FJsonToForms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MohdShamweel%2FJsonToForms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MohdShamweel%2FJsonToForms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MohdShamweel","download_url":"https://codeload.github.com/MohdShamweel/JsonToForms/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246122259,"owners_count":20726822,"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":["android","dynamic-form","form-builder","forms","json-forms"],"created_at":"2024-07-31T21:00:21.506Z","updated_at":"2025-03-29T00:34:11.155Z","avatar_url":"https://github.com/MohdShamweel.png","language":"Java","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# JsonToForms\n\nA simple library which uses JSON to build forms\n\n![3](https://user-images.githubusercontent.com/34341190/69896856-a80adf00-1369-11ea-9524-13b0e5f8d57b.gif)\n\n## Installation\n\nStep 1. Add the JitPack repository to your build file:\n\n```bash\nrepositories {\n\t...\n\tmaven { url 'https://jitpack.io' }\n\t}\n\n```\n  \nStep 2. Add the dependency\n\n\n```bash\ndependencies {\n\t  implementation 'com.github.MohdShamweel:JsonToForms:0.1.0'\n                \n     //Support Material dependency\n     implementation 'com.google.android.material:material:1.1.0-alpha09'\n\t     }\n\t\n```\n\nStep 3. The dependency contains Java 8 bytecode. Add the following to build.gradle\n```bash\n           android {\n               compileOptions {\n                   sourceCompatibility 1.8\n                   targetCompatibility 1.8\n               }\n           }\n```\n\nStep 4. The Activity which contains forms must be a descendant of Material Theme:\n\n```bash\nparent=\"Theme.MaterialComponents.Light.DarkActionBar\"\n``` \nStep 5. Sync the Project for gradle to finish.\t\n\n## Usage\n\n1. Initialize the Hashmap (basically it clears the list):\n```bash\nDataValueHashMap.init();\n```\n2. Use the adapter and Object of this library:\n```bash\nFormAdapter mAdapter;\nList\u003cJSONModel\u003e jsonModelList = new ArrayList\u003c\u003e();\n```\n\n3. Initialize the adapter:\n```bash\nmAdapter = new FormAdapter(jsonModelList, this, this);\n```\n\n4. Implement your Activity to access methods\n```\nimplements JsonToFormClickListener\n```\n5. Implemented Methods\n```bash\n @Override\n    public void onAddAgainButtonClick() {\n        Toast.makeText(this, \"Add Again button click\", Toast.LENGTH_SHORT).show();\n    }\n\n @Override\n    public void onSubmitButtonClick() {\n        Toast.makeText(this, \"Add Submit button click\", Toast.LENGTH_SHORT).show();\n    }\n```\n6. To check if fields are validated use the method:\n```bash\nif (!CheckFieldValidations.isFieldsValidated(recyclerView, jsonModelList)){\n            Toast.makeText(this, \"Validation Failed\", Toast.LENGTH_SHORT).show();\n    }\n```\n7. To get data:\n```bash\n//Combined Data:\n   JSONObject jsonObject = new JSONObject(DataValueHashMap.dataValueHashMap);\n   Log.d(\"onSubmitButtonClick: \", jsonObject.toString());\n\n\n//If single value required for corresponding _id's:\n   for (Map.Entry\u003cString, String\u003e hashMap : DataValueHashMap.dataValueHashMap.entrySet()){\n       String key = hashMap.getKey(); //  _id of the JSONOModel provided\n       String value = hashMap.getValue(); //value entered for the corresponding _id\n       Log.d(key, value);\n     }\n```\n\n## Fields Types\n```\nTYPE_TEXT = 1;\nTYPE_EDITTEXT = 2;\nTYPE_SPINNER = 3;\nTYPE_RADIO = 4;\nTYPE_DATE = 5;\nTYPE_SPACE = 6;\nTYPE_CHECKBOX = 7;\nTYPE_ADD_AGAIN_BUTTON = 9;\nTYPE_SUBMIT_BUTTON = 10;\n```\n\n## Sample JSON\n\n```bash\n[\n  {\n    \"_id\": \"text_1\",\n    \"text\": \"Hi! I'm textview\",\n    \"hint\": \"Hi! I'm textview\",\n    \"type\": 1\n  },\n  {\n    \"_id\": \"edittext_1\",\n    \"text\": \"Hi! I'm edittext(Enter Numbers)\",\n    \"hint\": \"Hi! I'm edittext(Enter Numbers)\",\n    \"input_type\": \"numbers\",\n    \"max_length\": 2,\n    \"type\": 2\n  },\n  {\n    \"_id\": \"edittext_2\",\n    \"text\": \"Hi! I'm edittext(Enter Numbers Decimal)\",\n    \"hint\": \"Hi! I'm edittext(Enter Numbers Decimal)\",\n    \"input_type\": \"numbers_decimal\",\n    \"max_length\": 7,\n    \"type\": 2\n  },\n  {\n    \"_id\": \"edittext_3\",\n    \"text\": \"Hi! I'm edittext(Enter text) *Required\",\n    \"hint\": \"Hi! I'm edittext(Enter text)\",\n    \"input_type\": \"text\",\n    \"is_required\": true,\n    \"max_length\": 30,\n    \"type\": 2\n  },\n  {\n    \"_id\": \"radio_group_1\",\n    \"text\": \"Hi! I'm radio group\",\n    \"is_required\": true,\n    \"list\": [\n      {\n        \"index\": 0,\n        \"index_text\": \"Radio 1\"\n      },\n      {\n        \"index\": 1,\n        \"index_text\": \"Radio 2\"\n      },\n      {\n        \"index\": 2,\n        \"index_text\": \"Radio 3\"\n      },\n      {\n        \"index\": 3,\n        \"index_text\": \"Radio 4\"\n      }\n    ],\n    \"type\": 4\n  },\n  {\n    \"_id\": \"spinner_1\",\n    \"text\": \"Hi! I'm spinner\",\n    \"list\": [\n      {\n        \"index\": 0,\n        \"index_text\": \"Item 1\"\n      },\n      {\n        \"index\": 1,\n        \"index_text\": \"Item 2\"\n      },\n      {\n        \"index\": 2,\n        \"index_text\": \"Item 3\"\n      },\n      {\n        \"index\": 3,\n        \"index_text\": \"Item 4\"\n      }\n    ],\n    \"type\": 3\n  },\n  {\n    \"_id\": \"again_button\",\n    \"text\": \"Hi! I'm add button\",\n    \"type\": 9\n  },\n  {\n    \"_id\": \"space_1\",\n    \"text\": \"Hi, I am Space\",\n    \"type\": 6\n  },\n  {\n    \"_id\": \"submit_button\",\n    \"text\": \"Submit\",\n    \"type\": 10\n  }\n]\n```\n\n## Example:\nTo know more about implementation please checkout the [Sample App](https://github.com/MohdShamweel/JsonToForms/tree/master/app)\n\n## Contributing\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update tests as appropriate.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMohdShamweel%2FJsonToForms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMohdShamweel%2FJsonToForms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMohdShamweel%2FJsonToForms/lists"}