Cleans up truncated json files.
Project description
# untruncate_json Python library to repair truncated json. Translated directly from the typescript original version
## Installation
`bash pip install untruncate_json ` ## Usage
In some cases, a partial json document is invalid and there is no way to recover. A common scenario using OpenAI’s chatbot is that the AI created json is truncated at the end of the document. This library will attempt to repair the json by adding the missing closing brackets.
If the context of the json is relatively simple and holds natural language, truncating the text might not degrade the final result much.
`python import untruncate_json assert untruncate_json.complete('{"foo": "bar') == '{"foo": "bar"}' `
## Goals My goal is for the library to be a pure python library that handles as many cases as the other libraries.
## Credits Original Typescript version by dphilipson, MIT license. Code translated by a lazy ChatGPT that didn’t want to translate the long switch blocks. Copilot translated the switch blocks.
## Prior Art
[untruncate-json](https://github.com/dphilipson/untruncate-json) - Original Typescript version
[truncjson](https://pypi.org/project/truncjson/) Cython implementation
[jsonfixer](https://pypi.org/project/jsonfixer/) Fork of half-json?
[half-json](https://pypi.org/project/halfjson/)
## Benchmarks
truncjson: 1.28
untruncate_json: 11.39
untruncate_json: 1.14 (if you run mypyc untruncate_json
jsonfixer: 23.06
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for untruncate_json-1.0.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85e74486dd645f77dea9f5000457ffe36a8f50acff661836d86cb033050113f2 |
|
MD5 | 5e655584a199d288068c591d9bb5947a |
|
BLAKE2b-256 | ba5605f487fb7c3a5f44294dfec8e674641305e63308d517f7b12524b5a57057 |
Hashes for untruncate_json-1.0.0-cp312-cp312-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 068404584418a3b6c35e8a862afd1e7063979945dbee9e28e6d33ed952f5da58 |
|
MD5 | 5e7c16c7ed1bd90e13b14a5971dbea2d |
|
BLAKE2b-256 | 6c0cd1da4835330e360acc1693887403e04500ef19f7ca62dbfc0dddf563e73c |
Hashes for untruncate_json-1.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3299f29e311ac8601d7cde80b413cee1711170ec1e5831677a6e297eb88ead7 |
|
MD5 | a1c67554ea108cecb82300aa36963abb |
|
BLAKE2b-256 | 1699756e9f6e665eaf0e27a7747bbcf0118267404b6c8ac75ff5601e19850c73 |
Hashes for untruncate_json-1.0.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9266cabfc934dc98a36d6cf31ee961bb63ba6c5a5f1ee4731d23d5d266cfb056 |
|
MD5 | 6d82a9f64d674cb02fc1f49d4c0b2b6b |
|
BLAKE2b-256 | 573a812126020b79c59f5e320f5f6e234fb74ee022747f4ca79d90ea1160ce8b |
Hashes for untruncate_json-1.0.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b49596c334b1f76ed7e073d0ef3d56f58e56174185ae28a8d8372d58365b699 |
|
MD5 | 3a3e5dc2cc6bcb756503bbc0db5a09b0 |
|
BLAKE2b-256 | b60be10381ca802d9ecaaa21e0c1cc5624c9b35fb0d8f7423afa0e51d645140d |
Hashes for untruncate_json-1.0.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18337ae7d35c97d3928fa194f20cca48d626e4f764f6793d38d072f06918fd63 |
|
MD5 | c04b2ac099788c281db6b23b0d0d8276 |
|
BLAKE2b-256 | 241af4addd36f363a1684408ae651d7091c8a6d58c61263480cdce5a9e62dd7f |
Hashes for untruncate_json-1.0.0-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5bb628dd7fd422db80344d082c3db04cd735e0a0fd2bf28e83198fc23e41493f |
|
MD5 | 6552c3c7f98a0a3428969041c74cbfc7 |
|
BLAKE2b-256 | c12a0e329d8403359b0cdcc24fea71970df49135189489a389faf3241846a154 |
Hashes for untruncate_json-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 064daffb01679823566b4ea77b36d5284a0cfdf957a762bfa616b1e2d8b71e62 |
|
MD5 | ed0dee66c1a12d07833ac630ac2c2624 |
|
BLAKE2b-256 | 93614f6a705a9e564ae955866331bc6ab5499d154ab8cc4b9600468eb17299d5 |
Hashes for untruncate_json-1.0.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95bbbe4162d91fb01d318c2be285b0b5886a41a4bdf5603b998cb10ec8c28ffb |
|
MD5 | 1d124db57340a334ae4e5e96e4dc1e41 |
|
BLAKE2b-256 | b4ce2a9db92c4ce41cc3a87ea30613629b40261968ae0232e2d5362bcd2f060b |
Hashes for untruncate_json-1.0.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1aa2fd4457e355ed35a6ed29bb787a967104d95fb387294a9ac03048a5f084bd |
|
MD5 | 55fee88ab1ac0fc28f5f14389dd57368 |
|
BLAKE2b-256 | dc86b10cda4271b948242e8ed0171e49d1153b40b230cc33d3e686ee6fbedc40 |
Hashes for untruncate_json-1.0.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e8a3a500f5f06a93743547ec1fd40f617c97debcc1ff63de795640bee0c9d84 |
|
MD5 | 433066105a557bab8ee983a784c0d045 |
|
BLAKE2b-256 | de884d6312bc4eda09b500e63ac2e98a0e8cee99292dc0a5bf58fa178438c43a |
Hashes for untruncate_json-1.0.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e78a30a01cb55b30bcbaad946a400556841ce4edef1b40758015681d4ca7c10 |
|
MD5 | cac18e3c68a0c0bda89f61d2dcd61b05 |
|
BLAKE2b-256 | 837f0a3a942a2c5e8442dd8d41d98169b748d1d91e76bb96e95641b4c5644309 |
Hashes for untruncate_json-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47a838580e61e1b5595ed52be551255b0d13b7cea14c26613ccdd4bebe7761e5 |
|
MD5 | 08d76bebd4506638fd5f32c129c8e516 |
|
BLAKE2b-256 | 1623859b12ef630b55dac3e4e86b478a23492c5030e3c4ded6dd38b2a8c89796 |
Hashes for untruncate_json-1.0.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b01d851ff835c2ef1db6b0f3e14a7b69920bf72e2b5fa8917bc60cea438c083d |
|
MD5 | 2cc6f732639d1147d08017f427236243 |
|
BLAKE2b-256 | b68c5599e100ecba81f5f901cf5607f2de833e678dd0a9e8693ec2ea52506044 |
Hashes for untruncate_json-1.0.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 942b453f34af55841145ca87244ca1839bd84d30ba62c3e9a787e0f56406b6d7 |
|
MD5 | ca730a2b4c3fce0a57fbdce1462e61b7 |
|
BLAKE2b-256 | 61b4c90d96271faeaa27d05bff416fc7486c4ba45151dbba620a13a0f18bef10 |
Hashes for untruncate_json-1.0.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8248fde917ea616c37304ebc5266902a3a1232a17fa5d5dd7c535fa74660af62 |
|
MD5 | 530e04777689c54e02aeb2407cf26dc7 |
|
BLAKE2b-256 | f0417f5b4427ff4ed9941bfea6b78cb2e2c9eb0de5e2d55ccbf922e3eea2f286 |
Hashes for untruncate_json-1.0.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df441cedf47a5009797a0d74e18bad8a3c3f5afad395c8bb120f4dfc87ee7abf |
|
MD5 | 9c5d9a98c951670fbcd170881dc05f8f |
|
BLAKE2b-256 | e1c74074532404f783f9266e0a06816cfad33902f1987860b12f9e5a03a35d7a |
Hashes for untruncate_json-1.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 467516e41fd3436e13c383a4ac9ee4a079b4786908a27512bd5a1a4f4e34ae67 |
|
MD5 | 0caa36383621829826ac531a099ee26c |
|
BLAKE2b-256 | 8c35a6933ac1acf4816300391d080dc0a27d3cc1d9e03c581216bbf954260b68 |
Hashes for untruncate_json-1.0.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd764c4e1265a05cf6a3ce10dc7b10eaee9d90ff5b117862edfb951f4c3f8c14 |
|
MD5 | 9857ab82fc67c967cb4225ba40b4b22e |
|
BLAKE2b-256 | 717d4f566a00059c08be6dea639dfc76c5f1b211d5844f88482070adeed3f7f0 |
Hashes for untruncate_json-1.0.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77c5b49449473df15b47120733b212165cb18f2fe491bca614507becad40f6a3 |
|
MD5 | 6fdbea25c5fc19e7db389621fcfab82d |
|
BLAKE2b-256 | b243e66760dc65caaaac32a6c10c4cd808603b4142a44b1f0afe86bab6d24215 |
Hashes for untruncate_json-1.0.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9a27d1cf05a6cc5b551c563a06dbaf330d622c3947da46909971f733b572b0a |
|
MD5 | 14dac9c33e459bdde8acbd92a36aeabb |
|
BLAKE2b-256 | b8547dc183617fc8b3c3cd6ca516b7cd102df1c73a77d96dbe873042b3281db4 |
Hashes for untruncate_json-1.0.0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b6f82909de785a08581027e2345682f890b862d38bcf0fcd6409b31d20ca0f9 |
|
MD5 | f9d46b5577a60f864f1ab6c7456ab00a |
|
BLAKE2b-256 | 2c465d5613a532de4bad39336c310a056d438a3c7330caad0cf383ab96e6386c |
Hashes for untruncate_json-1.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8ebaef95620decb5e906fa2d23682eb20ea616bae89096e60f57018bbc93bdd |
|
MD5 | 321e4afc895a5d0bf4216933091e716b |
|
BLAKE2b-256 | 918e36f69f566d6be7c41f1319b82bed162d7bce529e4eac393f67809b1d3835 |
Hashes for untruncate_json-1.0.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d39f84b0f343e69b7dae32f409e8871a7653ead7b86eedd421b7ab885421744 |
|
MD5 | 5fcf2f2d2871a0f23db67f8279af9cfa |
|
BLAKE2b-256 | d902c62efe8d09629b2ba9c40a176394260c0221646e9b4705c389399f03b1ba |
Hashes for untruncate_json-1.0.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c5072da8d8b5f768ddcb64509d1eee1762d139cc3c89b770f87f3b76593a848 |
|
MD5 | bcbfcd42acc58edc87cb0d654a885ccb |
|
BLAKE2b-256 | c9f6a13b3fbd7d9c77f69dcdabdf2be0428a57ea0bac562f86cdd42eb1397763 |