{"id":22927082,"url":"https://github.com/pityubak/xmlgrinder","last_synced_at":"2025-09-02T01:33:05.107Z","repository":{"id":144159780,"uuid":"242568405","full_name":"Pityubak/XmlGrinder","owner":"Pityubak","description":null,"archived":false,"fork":false,"pushed_at":"2020-06-05T19:37:22.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-01T15:48:45.538Z","etag":null,"topics":["annotations","xml","xml-parsing","xml-serialization"],"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/Pityubak.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":"2020-02-23T18:24:57.000Z","updated_at":"2020-06-05T19:37:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"04d21679-8382-4b5b-b5de-64f2673a2023","html_url":"https://github.com/Pityubak/XmlGrinder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Pityubak/XmlGrinder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pityubak%2FXmlGrinder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pityubak%2FXmlGrinder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pityubak%2FXmlGrinder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pityubak%2FXmlGrinder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pityubak","download_url":"https://codeload.github.com/Pityubak/XmlGrinder/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pityubak%2FXmlGrinder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273218428,"owners_count":25065913,"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-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":["annotations","xml","xml-parsing","xml-serialization"],"created_at":"2024-12-14T09:13:28.176Z","updated_at":"2025-09-02T01:33:05.089Z","avatar_url":"https://github.com/Pityubak.png","language":"Java","readme":"# XmlGrinder\n\n\n\n## Overview\n\n#### Serializing a simple object:\n\n```java\n@Xml\npublic class Single {\n\n    @Attribute\n    private int id;\n\n    @XmlElement\n    private String name;\n\n    @XmlElement\n    private int age;\n\n    public Single(int id, String name, int age) {\n        this.id = id;\n        this.name = name;\n        this.age = age;\n    }\n\n    //getters and setters here(optional)\n}\n```\nTo serialize an instance of the above object a XmlGrinder is required.\n\n```java\n    XmlGrinder grinder=new XmlGrinder();\n     \n    Single single=new Single(2,\"Single\",20);\n    grinder.write(single, \"E:\\\\single.xml\");\n    \n```\nAnd output:\n    \n   \n```xml\n    \u003cSingle id=\"2\"\u003e\n      \u003cname\u003eSingle\u003c/name\u003e\n      \u003cage\u003e20\u003c/age\u003e\n    \u003c/Single\u003e\n ```\n \n #### Deserializing a simple object:\n \n Deserialization is really easy, the read method is used, which produces an instance of the annotated object. \n \n ```java\n \n   XmlGrinder grinder = new XmlGrinder();\n        \n   Single single=grinder.read(Single.class, \"E:\\\\single.xml\");\n ```\n \n #### Serializing nested class and list\n \n To serialize more complex object the empty constructor always is required.\n \n ```java\n @Xml\npublic class Nested {\n    \n    @Attribute\n    private String name;\n    \n    @XmlElement\n    private String address;\n    \n    @XmlElement\n    private String email;\n    \n    //Empty constructor is neccesary\n    public Nested() {\n    }\n\n    public Nested(String name, String address, String email) {\n        this.name = name;\n        this.address = address;\n        this.email = email;\n    }\n    \n    //getters and setters here(optional)\n}\n\n@Xml\npublic class NestedWithList {\n    \n    @Attribute\n    private int index;\n    \n    @XmlElement\n    private String name;\n    \n    @XmlElement\n    private Nested nested;\n    \n    @XmlList\n    private List\u003cSingle\u003e singles;\n\n    //Empty constructor is necessary\n    public NestedWithList() {\n    }\n\n    public NestedWithList(int index, String name, Nested nested, List\u003cSingle\u003e singles) {\n        this.index = index;\n        this.name = name;\n        this.nested = nested;\n        this.singles = singles;\n    }\n\n    //getters and setters here(optional)\n    \n}\n```\nAnd the output:\n\n```xml\n\u003cNestedWithList index=\"345\"\u003e\n    \u003cname\u003enestedWithList\u003c/name\u003e\n    \u003cnested name=\"Harley\"\u003e\n        \u003caddress\u003eGotham\u003c/address\u003e\n        \u003cemail\u003enested@withlist.com\u003c/email\u003e\n    \u003c/nested\u003e\n    \u003csingles\u003e\n        \u003cSingle id=\"1\"\u003e\n            \u003cname\u003eJoker\u003c/name\u003e\n            \u003cage\u003e34\u003c/age\u003e\n        \u003c/Single\u003e\n        \u003cSingle id=\"2\"\u003e\n            \u003cname\u003eBatman\u003c/name\u003e\n            \u003cage\u003e66\u003c/age\u003e\n        \u003c/Single\u003e\n    \u003c/singles\u003e\n\u003c/NestedWithList\u003e\n\n```\n\n#### Deserializing a nested object and/or list:\n\nDeserialization of complex object is similar as above.\n\n```java\n   XmlGrinder grinder = new XmlGrinder();\n\n   NestedWithList nestedWithList=grinder.read(NestedWithList.class, \"E:\\\\nest.xml\");\n```\n#### Limitations\n\nIt does not support namespace or any other type of collection. More efficient version is possible, some algorithm will be better\nand it would be worth to write custom parser/and writer.\n\n#### Note\nThis is example project of Liberator 0.3\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpityubak%2Fxmlgrinder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpityubak%2Fxmlgrinder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpityubak%2Fxmlgrinder/lists"}