跳转到内容
Agentic Workflowdocs
v0.8.2免费安装

节点 / builtin / datatransformation

JSON

Parse, build, pick from and repair JSON

数据 扩展程序网页应用

此内容尚不支持你的语言。

Parse, build, pick from, merge and repair JSON.

The JSON node has five operations:

  • Parse turns JSON text into data the next nodes can use. With Repair If Needed on (the default), it first fixes nearly-valid JSON.
  • Stringify turns data into JSON text, indented when Pretty Print is on.
  • Pick by path reads one value with a dot path, such as product.offers.price.
  • Merge deep-merges Merge With into the JSON. Objects are merged key by key; lists and plain values are replaced, and Merge With wins on conflicts.
  • Repair fixes JSON text without parsing it, and reports what it changed.

Repair undoes a fixed set of common mistakes, in this order: a Markdown code fence around the JSON, text before or after it, // and /* */ comments, single quotes, keys without quotes, trailing commas, and a cut-off end. It stops as soon as the text is valid. It never invents values: a cut-off end is closed, and a key whose value never arrived is dropped. Valid JSON is never changed.

  • Read an AI model’s answer that should be JSON but comes wrapped in a code fence or has a trailing comma.
  • Turn JSON-LD from Get Structured Data into fields you can address.
  • Build a JSON string for an API body or a file with Stringify.
  • To keep or drop whole fields of an item, Edit Fields or Pick Field are simpler.
设置项类型作用
Operation ChoiceWhat to do with the JSON. Options: Parse, Stringify, Pick by path, Merge, Repair. 默认值:Parse
JSON ValueThe JSON text or data to work on.
Source Field TextField on the incoming item to read, when JSON above is left empty.
Path TextDot path to read, for example product.offers.price.
Merge With ValueThe object merged into the JSON. Its values win on conflict.
Repair If Needed ToggleTry to fix nearly-valid JSON before parsing it. 默认值:On
Pretty Print ToggleIndent the output of Stringify. 默认值:Off
Put Result In Field TextName of the field holding the answer. 默认值:data

The node finds its input in this order: the JSON field (for example {{ $input.output }}), then the field named in Source Field (dots allowed), then the whole incoming item.

Repair If Needed also applies to text given to Stringify, Pick by path and Merge, since that text is parsed first.

  • Output
  • Parse: a parsed object becomes the item itself, so you can use {{ $input.title }} directly. A list becomes one item per entry. Any other value goes in Put Result In Field. When repair was needed, a _repaired field lists the fixes.
  • Stringify: the JSON text, in Put Result In Field.
  • Pick by path and Merge: an object result becomes the item; anything else goes in Put Result In Field.
  • Repair: the fixed text in Put Result In Field, plus repaired (whether anything changed), steps (the fixes applied, such as codeFence or trailingCommas) and valid (whether the text now parses).

None. This node needs no connection and has no slots for other nodes.

  1. A Basic LLM Chain is asked to answer with a JSON object holding title and tags.
  2. JSON with Operation Parse, JSON set to the model’s answer, and Repair If Needed on. A reply wrapped in a code fence still parses.
  3. Notion creates a page titled {{ $input.title }}.
  • “This is not valid JSON: … Turn on “Repair If Needed” to try to fix it.“ The text is broken and repair is off. Turn Repair If Needed on.
  • “This could not be read as JSON even after repair: …” The text is more than nearly valid, for example plain prose with no braces. Ask the model for JSON only, or check the field you read.
  • “Path “…” does not exist in this JSON.“ Compare Path with the real structure. List entries use their number, for example items.0.name.
  • “Merge needs something to merge in. Fill in “Merge With”.“ Fill in Merge With.
  • “Repair works on JSON text. This input is already parsed data.” The input is already data, so there is nothing to repair. Use Parse or Pick by path instead.
编辑此页

最近更新:

Was this page useful?
向 Aria 询问“JSON”