{"id":18643625,"url":"https://github.com/lemberg/android-json-serializable-sample","last_synced_at":"2025-05-08T04:41:35.119Z","repository":{"id":70144912,"uuid":"48380804","full_name":"lemberg/android-json-serializable-sample","owner":"lemberg","description":null,"archived":false,"fork":false,"pushed_at":"2016-01-31T21:01:53.000Z","size":101,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-31T17:08:58.169Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/lemberg.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}},"created_at":"2015-12-21T16:01:32.000Z","updated_at":"2017-05-07T06:46:19.000Z","dependencies_parsed_at":"2023-04-23T21:54:21.563Z","dependency_job_id":null,"html_url":"https://github.com/lemberg/android-json-serializable-sample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemberg%2Fandroid-json-serializable-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemberg%2Fandroid-json-serializable-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemberg%2Fandroid-json-serializable-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemberg%2Fandroid-json-serializable-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lemberg","download_url":"https://codeload.github.com/lemberg/android-json-serializable-sample/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253002780,"owners_count":21838635,"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":[],"created_at":"2024-11-07T06:07:35.769Z","updated_at":"2025-05-08T04:41:35.092Z","avatar_url":"https://github.com/lemberg.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# android-json-serializable-sample\n\n**What is it?**\n\nJsonSerializable it's a simple library based on Gson that allows to serialize/deserialize objects,\nLists of objects, Maps of objects, etc.\n\n**Getting started**\n\n1. Checkout library project from [there](https://lemberg.codebasehq.com/projects/lemberg-internal-android/repositories/json-serializable/tree/dev).\n2. Open project's root folder using terminal (*nix-based OS) or CMD (Windows family).\n3. Use `mvn package` command to build jar library.\n4. After packaging, copy *jsonsserializable.jar*  into `\u003cproject path\u003e/\u003cproject name\u003e/app/libs/` folder.\n5. Rebuild your project.\n\n**Using JsonSerializable**\n\n* Simple objects example:\n```java\n\n        String name = \"TestName\";\n        String surname = \"TestSurname\";\n        int age = 20;\n\n        //Creating object for serialization\n        UserProfile profile = new UserProfile(name, surname, age);\n        \n        //Object serialization\n        String jsonProfile = JsonSerializable.toJson(profile);\n\n        //Object deserialization\n        UserProfile userProfileFromJson = JsonSerializable.fromJsonUnsafe(UserProfile.class, jsonProfile);\n\n```\n\n* List of objects\n```java\n\n        String name = \"TestName\";\n        String surname = \"TestSurname\";\n        int age = 20;\n\n        //Creating list of objects\n        List\u003cUserProfile\u003e userProfileList = new ArrayList\u003c\u003e(5);\n        for (int i = 0; i \u003c 5; i++) {\n\n            String tmpName = name + i;\n            String tmpSurname = name + i;\n            int tmpAge = age + i;\n\n\n            userProfileList.add(new UserProfile(tmpName, tmpSurname, tmpAge));\n        }\n\n        //List serialization\n        String jsonProfiles = JsonSerializable.toJson(userProfileList);\n\n        //List deserialization\n        List\u003cUserProfile\u003e userProfileListFromJson = JsonSerializable.toList(jsonProfiles, UserProfile.class);\n\n```\n\n* Map of objects\n```java\n\n        String name = \"TestName\";\n        String surname = \"TestSurname\";\n        int age = 20;\n\n\n        List\u003cUserProfile\u003e userProfileList = new ArrayList\u003c\u003e(5);\n        for (int i = 0; i \u003c 5; i++) {\n\n            String tmpName = name + i;\n            String tmpSurname = name + i;\n            int tmpAge = age + i;\n\n\n            userProfileList.add(new UserProfile(tmpName, tmpSurname, tmpAge));\n        }\n\n        //Creating map of objects\n        Map\u003cInteger, UserProfile\u003e userProfileMap = new HashMap\u003c\u003e();\n        int i = 0;\n        for (UserProfile profileItem : userProfileList) {\n            userProfileMap.put(i, profileItem);\n            i++;\n        }\n\n        //Map serialization\n        String jsonMapProfiles = JsonSerializable.toJson(userProfileMap);\n\n        //Map deserialization\n        Map\u003cInteger, UserProfile\u003e userProfileMapFromJson = JsonSerializable.toMap(jsonMapProfiles, Integer.class, UserProfile.class);\n\n\n```\n\n**License**\n\n```\nThe MIT License (MIT)\n\nCopyright (c) 2015 Lemberg Solutions\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemberg%2Fandroid-json-serializable-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flemberg%2Fandroid-json-serializable-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemberg%2Fandroid-json-serializable-sample/lists"}