{"id":16348452,"url":"https://github.com/devinus/jsonerl","last_synced_at":"2025-04-12T12:31:41.660Z","repository":{"id":712884,"uuid":"359720","full_name":"devinus/jsonerl","owner":"devinus","description":"yet another but slightly different erlang \u0026lt;-\u0026gt; json encoder/decoder","archived":false,"fork":false,"pushed_at":"2009-11-03T19:09:48.000Z","size":78,"stargazers_count":3,"open_issues_count":0,"forks_count":36,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-04T20:45:46.427Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Erlang","has_issues":false,"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/devinus.png","metadata":{"files":{"readme":"README","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":"2009-11-03T18:43:51.000Z","updated_at":"2022-08-15T13:27:45.000Z","dependencies_parsed_at":"2022-07-07T15:08:21.504Z","dependency_job_id":null,"html_url":"https://github.com/devinus/jsonerl","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/devinus%2Fjsonerl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devinus%2Fjsonerl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devinus%2Fjsonerl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devinus%2Fjsonerl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devinus","download_url":"https://codeload.github.com/devinus/jsonerl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248566531,"owners_count":21125680,"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-10-11T00:52:10.574Z","updated_at":"2025-04-12T12:31:40.112Z","avatar_url":"https://github.com/devinus.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"It is modified version on Bob Ippolito's \u003cbob@mochimedia.com\u003e mochijson2 module, one can find in excellent mochiweb, erlang webserver.\n\nYet another JSON (RFC 4627) library for Erlang. jsonerl works with binaries as strings, arrays as lists (without an {array, _}) wrapper and it only knows how to decode UTF-8 (and ASCII).\n\nIt has the following mapping:\n\nErlang data type:        =\u003e          JavaScript data type:        =\u003e          Erlang data type:\n-----------------------------------------------------------------------------------------------\n\n1.    atom true                            boolean true                             atom true  \n\n2.    atom false                           boolean false                            atom false\n\n3.    atom undefined                       null                                     atom  undefined                         \n\n4.    any other atom                       string                                   binary holding string\n\n5.    list                                 array                                    list\n \n6.    number                               number                                   number\n\n7.    binary                               string                                   binary   \n\n8.    proptuple                            object                                   proptuple\n-----------------------------------------------------------------------------------------------\n\nNote: proptuple is result of passing proplist to list_to_atom bif ;)\nThis is concept of mine to nicely model javascript object without a need of tagging structures on erlang side.\n\nEg. JavaScript object \n\n{\n     name: \"Luc Besson\",\n     year_of_birth: 1959,\n     city: \"Paris\",\n     photo: \"http://is.gd/3pYJF\",\n     movies: [\"Taken\",\"Bandidas\",\"Taxi\"]\n}\n\nresults in\n\n{\n  {\u003c\u003c\"name\"\u003e\u003e, \u003c\u003c\"Luc Besson\"\u003e\u003e},\n  {\u003c\u003c\"year_of_birth\"\u003e\u003e, 1959},\n  {\u003c\u003c\"city\"\u003e\u003e, \u003c\u003c\"Paris\"\u003e\u003e},\n  {\u003c\u003c\"photo\"\u003e\u003e, \u003c\u003c\"http://is.gd/3pYJF\"\u003e\u003e},\n  {\u003c\u003c\"movies\"\u003e\u003e, [\u003c\u003c\"Taken\"\u003e\u003e,\u003c\u003c\"Bandidas\"\u003e\u003e,\u003c\u003c\"Taxi\"\u003e\u003e]}\n}\n\n-----------------------------------------------------------------------------------------------\n\nAdditionally there is utility macros delivered with jsonerl that helps turning erlang records to json and back. \n\nFor example:\n\n-include(\"jsonerl.hrl\").\n-record(artist, {name, year_of_birth, city, photo, movies}).\n\nArtist = #artist{name = \u003c\u003c\"Luc Besson\"\u003e\u003e, year_of_birth = 1959, city = \u003c\u003c\"Paris\"\u003e\u003e, photo = \u003c\u003c\"http://is.gd/3pYJF\"\u003e\u003e, movies = [\u003c\u003c\"Taken\"\u003e\u003e,\u003c\u003c\"Bandidas\"\u003e\u003e,\u003c\u003c\"Taxi\"\u003e\u003e]},\nJson = ?record_to_json(artist, Artist),\nArtist = ?json_to_record(artist, Json).\n\n\nthe resulting json will be:\n\n\u003cpre lang=\"javascript\" line=\"1\"\u003e\n{\n     name: \"Luc Besson\",\n     year_of_birth: 1959,\n     city: \"Paris\",\n     photo: \"http://is.gd/3pYJF\",\n     movies: [\"Taken\",\"Bandidas\",\"Taxi\"]\n}\n\n\n\n\n\n  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevinus%2Fjsonerl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevinus%2Fjsonerl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevinus%2Fjsonerl/lists"}