用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/cxcscmu/SkillLearnBench --skill run2-python-scala-json-circe命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Handles reading, populating, and saving .docx files using the python-docx library. Use this skill for any tasks involving template filling or modifying Word documents.
Perform various data analysis on SEC 13-F and obtain some insights of fund activities such as number of holdings, AUM, and change of holdings between two quarters.
This skill includes search capability in 13F, such as fuzzy search a fund information using possibly inaccurate name, or fuzzy search a stock cusip info using its name.
基于 SOC 职业分类
正在显示 SKILL.md
| name | run2_python-scala-json-circe |
| description | Parsing and handling JSON safely in Scala using io.circe |
In Python, JSON values are often recursive union types (e.g. str | int | list | dict) parsed dynamically by json.loads.
In Scala, recursive sum types for JSON are safely modeled using io.circe.Json (an Algebraic Data Type).
JsonValue = Union[str, int, float, bool, None, list["JsonValue"], dict[str, "JsonValue"]]
def tokenize(self, value: JsonValue) -> Token:
return Token(json.dumps(value))
import io.circe.Json
import io.circe.syntax._
class JsonTokenizer(val pretty: Boolean = false) {
def tokenize(value: Json): Token = {
// Circe handles AST formatting out-of-the-box
val jsonStr = if (pretty) value.spaces2 else value.noSpaces
Token(jsonStr, TokenType.STRUCTURED, Map("json" -> true))
}
}
Python often accesses elements via value["key"] or value[idx] which can raise errors.
Scala's Circe allows traversing cleanly:
def tokenizePath(value: Json, path: String): Option[Token] = {
val parts = path.split('.')
var current: Option[Json] = Some(value)
for (part <- parts if current.isDefined) {
val jsonOpt = current.get
// Safe object access: .asObject and then .flatMap(_(part))
current = if (jsonOpt.isObject && jsonOpt.asObject.exists(_.contains(part))) {
jsonOpt.asObject.flatMap(_(part))
}
// Safe array access: .asArray and index bounds checking
else if (jsonOpt.isArray && part.forall(_.isDigit)) {
val idx = part.toInt
val arr = jsonOpt.asArray.get
if (idx >= 0 && idx < arr.size) Some(arr(idx)) else None
} else {
None
}
}
current.map(tokenize)
}
Note: Alternatively, circe's Cursor or optics can be used for deep traversals, but iterating AST options is functionally equivalent to the Python behavior.