{"by":"Areibman","descendants":0,"id":39881753,"kids":[39902514,39881760],"score":38,"text":"Hey HN! Jaiqu is an AI agent for creating repeatable JSON transforms using jq query language syntax.<p>Jaiqu translates complex JSON structures into repeatable jq queries. jq is a command line utility built for fast, reliable JSON queries. Jaiqu takes advantage of the LLMs for both constructing jq queries as well as using feedback to fix errors&#x2F;invalid results if those queries are incorrect.<p>Writing code to parse JSON is super annoying. It usually involves manually reading huge JSON balls, parsing the keys in a language of your choice, and pulling the data manually. Also, you&#x27;re likely to run into key mismatches (i.e. source data might have &quot;customer_id&quot; as a key but my table is &quot;user_id&quot;), so you would have to write the translation dictionaries by hand.<p>This struck me as a task that was analogous to the many AI &quot;natural language to SQL&quot; editors out there. However, there were a lot of consistency issues where the LLMs would not produce functioning code. So I wrote an AI agent that does it for me.<p>It only takes two args:\n1. A blob of messy JSON containing data you want\n2. A JSON schema formatted in the way you want<p>Jaiqu generates a repeatable jq query that collects the data in the exact JSON schema you specify. This way, you can run this query as many times you want or save it as a config without having to prompt LLMs each and every time.<p>This tool beats the standard &quot;prompt ChatGPT for a jq query&quot; because by and large, LLMs don&#x27;t perform too well when writing DSLs like jq. Jaiqu essentially works by:\n1. Fuzzy matching each key against your schema to make sure it&#x27;s available to query\n2. Writing individual jq queries to fetch and transform those keys\n3. Compiling each individual query into a single complex jq query. \n4. Feeding back any errors or data mismatches to a &quot;self-healing&quot; loop that adjusts the queries accordingly until it works.<p>Would love to hear thoughts or feedback. This has saved our team a ton of time internally, so hopefully it can help others as well.","time":1711863737,"title":"Show HN: Write JSON processor queries (jq) in natural language","type":"story","url":"https://github.com/AgentOps-AI/Jaiqu"}