{"id":13813646,"url":"https://github.com/torfsen/barely_json","last_synced_at":"2025-04-15T03:54:13.759Z","repository":{"id":52705785,"uuid":"91106984","full_name":"torfsen/barely_json","owner":"torfsen","description":"A Python parser for data that only looks like JSON","archived":false,"fork":false,"pushed_at":"2023-07-29T14:55:48.000Z","size":35,"stargazers_count":65,"open_issues_count":3,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T03:54:07.597Z","etag":null,"topics":["json","parser","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","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/torfsen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2017-05-12T15:50:32.000Z","updated_at":"2024-12-27T00:26:47.000Z","dependencies_parsed_at":"2024-07-30T16:58:12.695Z","dependency_job_id":"0e1daa0f-ccb9-42ee-b0aa-da7f7ef23720","html_url":"https://github.com/torfsen/barely_json","commit_stats":{"total_commits":22,"total_committers":4,"mean_commits":5.5,"dds":"0.13636363636363635","last_synced_commit":"858a8a83f59ea6decc6d78930804750addd819a3"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torfsen%2Fbarely_json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torfsen%2Fbarely_json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torfsen%2Fbarely_json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torfsen%2Fbarely_json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/torfsen","download_url":"https://codeload.github.com/torfsen/barely_json/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249003955,"owners_count":21196794,"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":["json","parser","python"],"created_at":"2024-08-04T04:01:24.208Z","updated_at":"2025-04-15T03:54:13.739Z","avatar_url":"https://github.com/torfsen.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Barely JSON\n\n[![GitHub Actions badge](https://github.com/torfsen/barely_json/actions/workflows/test.yml/badge.svg)](https://github.com/torfsen/barely_json/actions/workflows/test.yml)\n\n*A Python package for parsing data that only looks like JSON*\n\n    from barely_json import parse\n    print(parse('[what is this?, , {perhaps, json: no}]'))\n\n    # Prints ['what is this?', '', {'perhaps': '', 'json': False}]\n\nQuite a bit of data looks like JSON at a first glance but turns out not to comply completely with the JSON specification -- often because the exporting software is broken, but sometimes simply because the format was never intended to be JSON in the first place.\n\nNo matter how you ended up with the data, now you want to parse it! However, most JSON parsers are pretty strict, so you're out of luck with your JSON-esque mess.\n\nThat's where *Barely JSON* steps in and tries to parse anything that remotely looks like JSON. In addition to the pure parsing, *Barely JSON* will also try to post-process your data into suitable Python types even if your data provider uses, for example, `on` and `off` as boolean literals.\n\n\n# Installation\n\nThe supported Python versions are 3.7 and later.\n\n    pip install barely_json\n\n\n# Usage\n\nThe main routine is `parse`:\n\n    \u003e from barely_json import parse\n    \u003e parse(\"[NaN, , {state: off, where's my value?}, NULL]\")\n\n    [nan, '', {'state': False, \"where's my value?\": ''}, None]\n\nAs you can see, `parse` by default tries to convert values that are illegal in JSON into hopefully appropriate Python types, which often works well. But sometimes that's not what you want, so you can disable the auto-conversion:\n\n    \u003e parse(\"[NaN, , {state: off, where's my value?}, NULL]\", resolver=None)\n\n    [\u003cIllegalValue 'NaN'\u003e,\n     \u003cIllegalValue ''\u003e,\n     {\u003cIllegalValue 'state'\u003e: \u003cIllegalValue 'off'\u003e,\n      \u003cIllegalValue \"where's my value?\"\u003e: \u003cIllegalValue ''\u003e},\n     \u003cIllegalValue 'NULL'\u003e]\n\nIn that case any value that's illegal or missing is wrapped in an instance of a special `IllegalValue` class. You can also provide your own resolver for illegal values, which is simply a callback that maps strings to arbitrary values:\n\n    \u003e from barely_json import default_resolver\n    \u003e\n    \u003e def my_resolver(text):\n    \u003e     if text.lower() == 'one':\n    \u003e         return 1\n    \u003e     return default_resolver(text)\n    \u003e\n    \u003e parse('[one, FALSE]', resolver=my_resolver)\n\n    [1, False]\n\nWhen writing your own resolver it's often handy to fall back to`default_resolver` after you've handled your special cases.\n\n\n# Change Log\n\nSee `CHANGELOG.md`.\n\n\n# License\n\nDistributed under the MIT license. See the file `LICENSE` for details.\n\n\n# Contributors\n\n* [@torfsen](https://github.com/torfsen)\n* [@tusharmakkar08](https://github.com/tusharmakkar08)\n* [@gvx](https://github.com/gvx)\n\n\n# Development\n\nClone the repository:\n\n    git clone https://github.com/torfsen/barely_json.git\n    cd barely_json\n\nInstall the development dependencies\n\n    pip install -r requirements-dev.txt\n\nRun the tests:\n\n    tox\n\nFor pull requests, the tests are run using GitHub actions.\n\n\n[virtualenv]: https://virtualenv.pypa.io\n[tox]: https://tox.readthedocs.io\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftorfsen%2Fbarely_json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftorfsen%2Fbarely_json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftorfsen%2Fbarely_json/lists"}