JSON Document Builder
JSON Document Builder takes one or more documents and turns the text of each one into a small JSON object with the key you choose. For example, with the key description, a document whose text is Ergonomic office chair ends up containing {"description":"Ergonomic office chair"}.
It gives texts a key and value structure before passing them on to other components that work with documents.
When to use it
- You need each text labelled with a field name, for example so a later system knows what it contains.
- You want to prepare documents in JSON format before splitting or storing them.
Configuration
| Field | What it does |
|---|---|
| Key | The name of the field the JSON object will have, for example description or summary. Always fill it in: it is the name under which the text is stored. |
| Connection | What to connect |
|---|---|
| Document | The documents whose text you want to convert. It accepts one or several, and only documents (outputs of type Document); outputs of type Data don’t connect here. |
Output
Documents returns the converted documents, one for each document received and in the same order. Each one contains only the JSON object with the key and the original text; any additional data the input document had is not kept. You can connect it, for example, to the Input of CharacterTextSplitter.
If something that is not a document reaches Document, the component fails when the flow runs.
Example
A furniture shop wants to store its product descriptions with a clear field name:
- Connect the documents with the descriptions to Document.
- In Key, type
description. - Connect Documents to the component that will process them next.
Each description comes out as {"description":"..."}.
Good practices
- Use short key names, without spaces or accents, so other systems can read them without trouble.