JSON, colors and links
Read and write JSON, convert colors, and split or encode links.
Read JSON as a shape value
Turns JSON text into one shape value following one of the shapes this module or server has declared, checking the text against that shape's fields as it goes. Every field then comes back with the right kind of value, so you never have to convert it again. If the text is not valid JSON, or does not match the shape, the action fails and you can catch it with 'Try'.
Inputs
| Name | Type | Required | Details |
|---|---|---|---|
| JSON text | Text | Yes | The JSON text to read. It must describe a single object, not a list. |
| Shape | Shape | Yes | Which shape the text has to match. It decides which fields must be present and what kind of value each one holds. |
Outputs
| Name | Type | Details |
|---|---|---|
| Shape value | Shape value | The shape value read from the text. |
Read JSON as a list of shape values
Turns JSON text that holds a list into shape values of one declared shape, checking every item against that shape's fields. Fields the shape does not declare are ignored. If the text is not valid JSON, is not a list, or an item does not match, the action fails and you can catch it with 'Try'.
Inputs
| Name | Type | Required | Details |
|---|---|---|---|
| JSON text | Text | Yes | The JSON text to read. It must describe a list of objects. |
| Shape | Shape | Yes | Which shape every item has to match. |
Outputs
| Name | Type | Details |
|---|---|---|
| Shape values | List of Shape value | The shape values read from the text, in list order. |
Write value as JSON
Turns a value into JSON text, so you can store it in one place or send it somewhere else. Read it back later with 'Read JSON as a shape value'.
Inputs
| Name | Type | Required | Details |
|---|---|---|---|
| Value | Any | Yes | The value to write out. Shape values, lists, lookup tables, texts, numbers and yes/no values all work. |
| Easy to read | Yes/No | No | Spread the text over several lines with indentation. Nice when a person reads it, longer when it is stored. |
Outputs
| Name | Type | Details |
|---|---|---|
| JSON text | Text | The value as JSON text. |
Color from hex
Builds a color from a hex code (e.g. #5865F2).
Inputs
| Name | Type | Required | Details |
|---|---|---|---|
| Hex | Text | Yes | Six-digit hex color, optionally prefixed with #. Must match ^#?[0-9a-fA-F]{6}$. |
Outputs
| Name | Type | Details |
|---|---|---|
| Color | Color | The resulting color. |
Color to hex
Returns the hex text for a color (e.g. #5865F2).
Inputs
| Name | Type | Required | Details |
|---|---|---|---|
| Color | Color | Yes | The color to convert. |
Outputs
| Name | Type | Details |
|---|---|---|
| Hex | Text | Hex text with leading #. |
Color from RGB
Builds a color from red, green, and blue components (0-255).
Inputs
| Name | Type | Required | Details |
|---|---|---|---|
| Red | Whole number | Yes | Red component (0-255). Value: 0 to 255. |
| Green | Whole number | Yes | Green component (0-255). Value: 0 to 255. |
| Blue | Whole number | Yes | Blue component (0-255). Value: 0 to 255. |
Outputs
| Name | Type | Details |
|---|---|---|
| Color | Color | The resulting color. |
Color to RGB
Splits a color into its red, green, and blue components (0-255). The inverse of Color from RGB.
Inputs
| Name | Type | Required | Details |
|---|---|---|---|
| Color | Color | Yes | The color to split. |
Outputs
| Name | Type | Details |
|---|---|---|
| Red | Whole number | Red component (0-255). |
| Green | Whole number | Green component (0-255). |
| Blue | Whole number | Blue component (0-255). |
Split URL into parts
Splits a URL into its parts (protocol, host, port, path, query, fragment). Fails if the URL is invalid.
Inputs
| Name | Type | Required | Details |
|---|---|---|---|
| URL | URL | Yes | The URL to split. |
Outputs
| Name | Type | Details |
|---|---|---|
| Protocol | Text | The scheme without the trailing colon, e.g. "https". |
| Host | Text | The hostname without port, lowercased, e.g. "example.com". |
| Port | Text | The port as text, or empty when the URL uses the scheme's default port. |
| Path | Text | The path, e.g. "/a/b"; "/" when the URL has no path. |
| Query | Text | The raw query without the leading "?"; empty when there is none. |
| Fragment | Text | The fragment without the leading "#"; empty when there is none. |
Get URL query parameter
Reads a single query parameter from a URL. Returns an empty value when the parameter is absent.
Inputs
| Name | Type | Required | Details |
|---|---|---|---|
| URL | URL | Yes | The URL to read the parameter from. |
| Parameter | Text | Yes | The name of the query parameter. Repeated parameters return the first value. |
Outputs
| Name | Type | Details |
|---|---|---|
| Value | Text | The parameter's value, or empty if it is not present. May be empty. |
URL-encode
Percent-encodes text so it is safe to use inside a URL component.
Inputs
| Name | Type | Required | Details |
|---|---|---|---|
| Text | Text | Yes | The text to encode. |
Outputs
| Name | Type | Details |
|---|---|---|
| Result | Text | The percent-encoded text. |
URL-decode
Decodes percent-encoded text. Fails if the input contains a malformed escape.
Inputs
| Name | Type | Required | Details |
|---|---|---|---|
| Text | Text | Yes | The percent-encoded text to decode. |
Outputs
| Name | Type | Details |
|---|---|---|
| Result | Text | The decoded text. |