codecobblers / dirtyjson

Python JSON parser for reading JSON objects out of JS files
Other
39 stars 7 forks source link

Big thanks for this project, it is really great for parsing json from AI! #7

Closed devlincashman closed 12 months ago

devlincashman commented 1 year ago

Thank you for creating the best python library for parsing messy json on the web! :)

Thought you might find it interesting that my use case is if you are using an ai chatbot like chatgpt to generate json, it often adds random text before, after or in the json, and is just generally not very respectful of the json spec lol. Also sometimes it gets cutoff in generating json by the context limit so you are left with half of a json object with all the closing brackets missing.

So far dirtyjson has done a great job of handling almost all of this. Only suggestion might be if there was some extra handling around half cutoff json blobs and a best effort attempt to try and turn it into a valid json object.

There is a npm module that focuses more on fixing badly terminated json, might offer some inspiration if you are interested: https://github.com/josdejong/jsonrepair

Overall mostly just wanted to say thanks! I was trying to write regex to parse out the json and was tearing my hair out but dirtyjson handled most of my problems on the first try.

scottkmaxwell commented 12 months ago

Thanks for the feedback. I'm really happy to hear that it has worked well for you.