一键导入
decoding-json
Decode and parse JSON strings with EYG.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Decode and parse JSON strings with EYG.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Work with the DNSimple API to manage domains and integrations.
Create and dispatch HTTP requests.
Work with the GitHub API to manage repositories, issues, and other resources.
When a user makes a location specific query (what is the weather tomorrow) or asks for anything relative to their location.
Manage a running ollama instance; start stop and list active models
Work with the Netlify API to manage sites and deployments.
| name | decoding-json |
| description | Decode and parse JSON strings with EYG. |
EYG is a strongly typed language.
When decoding JSON it MUST also be passed into a useful datastructure.
The @json package is for decoding JSON.
let {parse: parse, decode: decode} = @json
let result = parse("true", decode.boolean)
// Will return Ok(True({}))
let result = parse("3", decode.integer)
// Will return Ok(3)
let result = parse("\"hi\"", decode.string)
// Will return Ok("hi)
EYG does not support parsing floats
let {parse: parse, decode: decode} = @json
let decoder = decode.list(decode.integer)
let result = parse("[1, 2, 3]", decoder)
// Will return Ok([1, 2, 3])
let {parse: parse, decode: decode} = @json
let decoder = decode.object((decoded) -> {
let foo = decode.field("foo", decode.integer, decoded)
{foo: foo}
})
parse("{"foo": 3}", decoder),
// will return Ok({foo: 3})
The json library returns string errors.
let {parse: parse, decode: decode} = @json
let result = parse("[]", decode.boolean)
// Will return Error("not a boolean")
The @json package includes the expect function for aborting on error.
Use this when making quick scripts
let {parse: parse, decode: decode, expect: expect} = @json
let result = expect(parse("true", decode.boolean), "failed to decode")
// Will return Error("not a boolean")