Knowledge File / AI技能杠杆
condense-json 1.0 发布
Simon Willison 宣布发布 condense-json 1.0,一个用于压缩 JSON 中重复字符串的 Python 库,可节省 LLM 日志的存储空间。
SOURCE / AI技能杠杆
MIN / 4
ACCESS / 会员
POST / 2026-08-03 06:19:59
原贴
查看原文原文
Release: condense-json 1.0 I'm trying to get braver at releasing 1.0 versions. This little library is a year and a half old now - I've applied some sensible and non-disruptive fixes and shipped the big 1.0 for it. Here's an example of what it can do, lifted from the README: { "foo" : { "bar" : { "string" : " This is a string with foxes in it " , "nested" : { "more" : [ " Here is a string " , " another with foxes in it too " ] } } } } Combine that with a replacements object: { "1" : " with foxes in it " } And condense_json(input_json, replacements) produces the following: { "foo" : { "bar" : { "string" : { "$r" : [ " This is a string " , { "$" : " 1 " }]}, "nested" : { "more" : [ " Here is a string " , { "$r" : [ " another " , { "$" : " 1 " }, " too " ]}] } } } } It scans for strings or substrings that are present in that replacements object and replaces those with a special {"$r": ...} syntax in the output. You can reverse the effect with uncondense_json(condensed, replacements) . The idea is to make it easier to store JSON that includes duplicated data from other related structures. I use it to save space in the SQLite logs generated by LLM - see PR #1586 for the latest iteration of that. Tags: json , projects , python , llm
中文翻译
发布:condense-json 1.0
我正在尝试更勇敢地发布 1.0 版本。这个库已经有一年半的历史了——我应用了一些明智且非破坏性的修复,并为其发布了重要的 1.0 版本。以下是从 README 中摘录的一个示例:
{ "foo" : { "bar" : { "string" : " This is a string with foxes in it " , "nested" : { "more" : [ " Here is a string " , " another with foxes in it too " ] } } } }
将其与一个替换对象组合:
{ "1" : " with foxes in it " }
然后 condense_json(input_json, replacements) 产生以下结果:
{ "foo" : { "bar" : { "string" : { "$r" : [ " This is a string " , { "$" : " 1 " }]}, "nested" : { "more" : [ " Here is a string " , { "$r" : [ " another " , { "$" : " 1 " }, " too " ]}] } } } }
它扫描出现在该替换对象中的字符串或子字符串,并在输出中用特殊的 {"$r": ...} 语法替换它们。你可以使用 uncondense_json(condensed, replacements) 反转效果。这样做的目的是使存储包含来自其他相关结构的重复数据的 JSON 更加容易。我用它来节省 LLM 生成的 SQLite 日志中的空间——参见 PR #1586 以获取最新迭代。
标签:json , projects , python , llm
核心信息
Simon Willison 宣布发布 condense-json 1.0,一个用于压缩 JSON 中重复字符串的 Python 库,可节省 LLM 日志的存储空间。
- Simon Willison 宣布发布 condense-json 1.0,一个用于压缩 JSON 中重复字符串的 Python 库,可节省 LLM 日志的存储空间。
- 原贴提到:Release: condense-json 1.0 I'm trying to get braver at releasing 1.0 ver
- 来源:simonwillison.net
试看内容
成为会员查看完整内容
你已经看到了这篇内容的前置整理,剩余深度部分仅对会员开放。
详细解读
信息差价值
参考来源
成为会员查看完整内容