{"id":31615312,"url":"https://github.com/bennyhat/xml_json","last_synced_at":"2025-10-06T11:13:59.012Z","repository":{"id":50217814,"uuid":"301019593","full_name":"bennyhat/xml_json","owner":"bennyhat","description":"Should you convert XML to JSON? Probably not. If you have to though, try a convention based converter.","archived":false,"fork":false,"pushed_at":"2025-02-10T20:49:37.000Z","size":65,"stargazers_count":6,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T20:11:18.503Z","etag":null,"topics":["convention","json","parker","xml"],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/bennyhat.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}},"created_at":"2020-10-04T01:47:25.000Z","updated_at":"2025-02-10T20:45:38.000Z","dependencies_parsed_at":"2022-09-26T20:52:41.287Z","dependency_job_id":null,"html_url":"https://github.com/bennyhat/xml_json","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/bennyhat/xml_json","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bennyhat%2Fxml_json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bennyhat%2Fxml_json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bennyhat%2Fxml_json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bennyhat%2Fxml_json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bennyhat","download_url":"https://codeload.github.com/bennyhat/xml_json/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bennyhat%2Fxml_json/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278598691,"owners_count":26013305,"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-10-06T02:00:05.630Z","response_time":65,"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":["convention","json","parker","xml"],"created_at":"2025-10-06T11:13:57.687Z","updated_at":"2025-10-06T11:13:59.005Z","avatar_url":"https://github.com/bennyhat.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# XmlJson\n\n[![hex.pm](https://img.shields.io/hexpm/v/xml_json.svg)](https://hex.pm/packages/xml_json)\n[![hex.pm](https://img.shields.io/hexpm/dt/xml_json.svg)](https://hex.pm/packages/xml_json)\n[![hex.pm](https://img.shields.io/hexpm/l/xml_json.svg)](https://hex.pm/packages/xml_json)\n[![github.com](https://img.shields.io/github/last-commit/bennyhat/xml_json.svg)](https://github.com/bennyhat/xml_json)\n\nShould you convert XML to JSON? Probably not.\n\nIf you have to though (and have decent control over the providers and consumers\nof the XML and JSON), then there are some decent conventions out there for\nlossless and near-lossless conversion, such as:\n\n- [`abdera`](http://wiki.open311.org/JSON_and_XML_Conversion/#the-abdera-convention)\n- [`badgerfish`](http://www.sklar.com/badgerfish/)\n- [`cobra`](http://wiki.open311.org/JSON_and_XML_Conversion/#the-cobra-convention)\n- [`gdata`](http://wiki.open311.org/JSON_and_XML_Conversion/#the-gdata-convention)\n- [`parker`](https://developer.mozilla.org/en-US/docs/Archive/JXON#The_Parker_Convention) (pretty lossy, but my personal favorite)\n- [`yahoo`](https://developer.yahoo.com/yql/guide/response.html#response-xml-to-json) (okay, maybe they're not all great, but they tried)\n- [`aws-api`](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/making-api-requests.html) (conventions seen in AWS XML based APIs)\n\nPresently this only supports Parker, BadgerFish and AWS API and is largely happy path\ntesting with the examples provided by each convention. That being said,\neventually this will come up to a `\u003e 0` major version when that is all worked\nout.\n\nOtherwise, this does NOT handle massive XML documents with grace, as it\nconverts to a full JSON/Map object in memory.\n\nA port of the great Python library [`xmljson`](https://pypi.org/project/xmljson/)\n\n## Usage\n\n### Parker\n```elixir\niex\u003e XmlJson.Parker.deserialize(\"\u003croot\u003e\u003cdog\u003ecat\u003c/dog\u003e\u003c/root\u003e\", preserve_root: true)\n{:ok, %{\"root\" =\u003e %{\"dog\" =\u003e \"cat\"}}}\n\niex\u003e XmlJson.Parker.serialize(%{\"root\" =\u003e %{\"dog\" =\u003e \"cat\"}}, preserve_root: \"root\")\n{:ok, \"\u003croot\u003e\u003cdog\u003ecat\u003c/dog\u003e\u003c/root\u003e\"}\n```\n\n### BadgerFish\n```elixir\niex\u003e XmlJson.BadgerFish.deserialize(\"\u003croot attr=\\\"hello\\\"\u003e\u003cdog\u003ecat\u003c/dog\u003e\u003c/root\u003e\")\n{:ok, %{\"root\" =\u003e %{\"@attr\" =\u003e \"hello\", \"dog\" =\u003e %{\"$\" =\u003e \"cat\"}}}}\n\niex\u003e XmlJson.BadgerFish.serialize(%{\"root\" =\u003e %{\"@attr\" =\u003e \"hello\", \"dog\" =\u003e %{\"$\" =\u003e \"cat\"}}})\n{:ok, \"\u003croot attr=\\\"hello\\\"\u003e\u003cdog\u003ecat\u003c/dog\u003e\u003c/root\u003e\"}\n```\n\n### AWS API\nBased on common conventions seen in at least the EC2 and ELBv2 XML APIs\n```elixir\niex\u003e XmlJson.AwsApi.deserialize(\"\u003croot\u003e\u003cmember\u003e\u003cdog\u003ecat\u003c/dog\u003e\u003c/member\u003e\u003c/root\u003e\")\n{:ok, %{\"root\" =\u003e [%{\"dog\" =\u003e \"cat\"}]}}\n\niex\u003e XmlJson.AwsApi.serialize(%{\"root\" =\u003e [%{\"dog\" =\u003e \"cat\"}]})\n{:ok, \"\u003croot\u003e\u003cmember\u003e\u003cdog\u003ecat\u003c/dog\u003e\u003cmember\u003e\u003c/root\u003e\"}\n\niex\u003e XmlJson.AwsApi.serialize_as_params(%{\"root\" =\u003e [%{\"dog\" =\u003e \"cat\"}, %{\"dog\" =\u003e \"horse\"}]})\n{:ok, %{\"root.member.1.dog\" =\u003e \"cat\", \"root.member.2.dog\" =\u003e \"horse\"}}\n```\n\n## Installation\n\nThe package can be installed by adding `xml_json` to your list of dependencies\nin `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:xml_json, \"~\u003e 0.5.0\"}\n  ]\nend\n```\n\nThe docs can be found at [https://hexdocs.pm/xml_json](https://hexdocs.pm/xml_json).\n\n## License\n\n[MIT](LICENSE) Copyright (c) 2020 Ben Brewer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbennyhat%2Fxml_json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbennyhat%2Fxml_json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbennyhat%2Fxml_json/lists"}