PALATINELABSDocsENES

Pages

↑↓ to moveEnter to openEsc to close

JSON package guide

Parse, read, change, convert and validate JSON documents.

Version 2.17.1. Installed versions can differ. Examples are illustrative and not tested.

Jump to actions

Packages

Prerequisites

Paths. Paths are case-sensitive. users[0].name and $.users[1].name select the names of the first and second user. List items are counted from 0, and $ is the whole document. Keys in brackets, such as ["item-name"], work. Wildcards, filters and recursive search do not. A null node counts as missing for actions that need a node.

Sample data. For each example, open a new session named sample with Source input=text and this Payload:

{"name":"ada","age":36,"tags":["x","y"],"users":[{"name":"a"},{"name":"b"}]}

Make the Dictionary $person$ with String name=ada and Number age=36, and the List $tags$ with the Strings q and r. For Get nodes, make the Table $entries$ with table actions, with three String columns and two rows:

nodePathdataTypeoutputKeyName
ageNumberyears
users[0].nameStringempty

Shared fields

InputUse
sessionThe name of an open document in this Run, such as sample⁠. It is not a credential. Set it in each session step.
nodePathA path such as users[0].name⁠, $.users[1].name or ["item-name"]⁠. See Prerequisites.
filePathA JSON file, such as samples/document.json⁠.

Value fields

Insert node and Update node value use these optional fields. Only the field that matches Value type is used.

InputEditor fieldType; default; requirementUse
valueTypeValue typeJsonValueTypedefault StringoptionalString⁠, Boolean⁠, Number⁠, Datetime⁠, List or Dictionary⁠.
stringValValueStringdefault ""optionalText, such as grace⁠. It is written as a JSON string.
boolValValueBooleandefault falseoptionaltrue⁠, false or a Boolean variable. It is written as JSON true or false⁠, without quotes.
numValValueNumberdefault 0optionalA number such as 7 or 12.5⁠, or a Number variable. It is written as a JSON number.
dateValValueDatetimedefault 0001-01-01T00:00:00+00:00optionalA Datetime variable, such as 2026-10-15T09:30:00+00:00⁠. It is written as date text, because JSON has no date type.
listValValueListdefault []optionalA List variable, such as $tags$⁠. Each item keeps its type.
dictionaryValValueDictionarydefault {}optionalA Dictionary variable, such as $details$ with Boolean active=true and Number count=2. It is written as an object, and each value keeps its type.

Actions

Insert node (jsonAddNodeValue)

Add a key to an object in an open session, or replace it. Only the session changes.

Inputs

InputEditor fieldType; default; requirementUse
sessionSession nameStringdefault ""requiredShared
nodePathNode pathStringdefault ""requiredShared. The node must be an object. Missing parents are not created.
keyNameKey nameStringdefault ""requiredThe key to write, such as age⁠. A key that exists is replaced. It does not add a list item.

Also uses the value fields.

Outputs

None.

Example

Set Session name=sample, Node path=users[0], Key name=age, Value type=Number and numVal=7. Read users[0].age with Get node value.

Expected result

The first user now has Number age 7, and Get node value gives 7. $ selects the root object. A list or a single value as the parent fails.

Back to actions

Convert JSON to Table (jsonConvertToTable)

Convert the whole session document into Table rows.

Inputs

InputEditor fieldType; default; requirementUse
sessionSession nameStringdefault ""requiredShared

Outputs

OutputTypeMeaning
resultTableString columns in the order each key first shows, and one row for each item of the root list, or one row for a root object. Save it in $rows$⁠.

Example

Start the session tabular with Source input=text and Payload=[{"a":1,"b":2},{"a":3}]. Set Session name=tabular and save result in the Table $rows$.

Expected result

The columns are a and b. The rows are 1, 2 and 3, empty. A single root object gives one row. Single values in a root list go in the first column. An empty list gives no rows and one String column Column1. A single value as the root fails.

Back to actions

Convert dictionary to JSON (jsonDictionaryToJSON)

Turn a Dictionary into JSON text. It needs no session.

Inputs

InputEditor fieldType; default; requirementUse
dictionaryDictionary variableDictionarydefault {}requiredA Dictionary variable such as $person$⁠. The type of each value sets its JSON type. A String with JSON text does not work here.

Outputs

OutputTypeMeaning
resultStringThe JSON text on one line. Save it in $jsonText$ to write a file or a request body.

Example

Set Dictionary variable=$person$. Save result in the String $jsonText$.

Expected result

The result is {"name":"ada","age":36}. The key order follows the Dictionary. An empty Dictionary gives {}. No file or session changes.

Back to actions

End session (jsonEndSession)

Close a session. Changes are not saved.

Inputs

InputEditor fieldType; default; requirementUse
sessionSession nameStringdefault ""requiredShared

Outputs

None.

Example

After Start session opens sample, set Session name=sample.

Expected result

The session and its document are gone. A later Get node value for sample fails until the session is opened again. An unknown or blank name fails.

Back to actions

Get node array (jsonGetNodeList)

Read a JSON list as a List of text, for a loop.

Inputs

InputEditor fieldType; default; requirementUse
sessionSession nameStringdefault ""requiredShared
nodePathNode key or pathStringdefault ""requiredShared

Outputs

OutputTypeMeaning
resultListOne String for each list item. Objects and lists become JSON text. Save it in $tagTexts$⁠.

Example

Set Session name=sample and Node key or path=tags. Save result in the List $tagTexts$.

Expected result

The List holds x and y. Numbers and Booleans also come back as text, and null items as empty text. An empty list gives an empty List. A missing node, a null node or a node that is not a list fails.

Back to actions

Get node value (jsonGetNodeValue)

Read one node as text. An object or a list comes back as JSON text.

Inputs

InputEditor fieldType; default; requirementUse
sessionSession nameStringdefault ""requiredShared
nodePathNode key or pathStringdefault ""requiredShared

Outputs

OutputTypeMeaning
resultStringA string without its JSON quotes, or JSON text for other nodes. Numbers also come back as String. Save it in $nameText$⁠.

Example

Set Session name=sample and Node key or path=$.users[1].name. Save result in the String $nameText$. For the whole document, use Node key or path=$.

Expected result

$nameText$ is b. Number age gives 36. A missing or null node fails, and does not give empty text.

Back to actions

Get nodes (jsonGetNodes)

Read several nodes into one Dictionary, each as the type you choose.

Inputs

InputEditor fieldType; default; requirementUse
sessionSession nameStringdefault ""requiredShared
entryListNodes entriesTabledefault empty TablerequiredA Table variable such as $entries$⁠. The String column nodePath names each node and is required. The optional String column dataType is String (the default), Number⁠, Boolean or Datetime⁠, in any case. The optional String column outputKeyName gives the result key; blank uses the path. See Prerequisites.

Outputs

OutputTypeMeaning
resultDictionaryOne key for each row, with a value of the row's dataType⁠. Save it in $picked$⁠.

Example

Set Session name=sample and Nodes entries=$entries$. Save result in the Dictionary $picked$.

Expected result

$picked$ holds Number years=36 and String users[0].name=a. An empty Table gives an empty Dictionary. If two rows give the same key, the later row wins. A missing node, an unknown dataType or a value that cannot be converted fails the whole step.

Back to actions

Start session (jsonStartSession)

Open JSON text or a file as a named session for the next steps. Opening the same name again replaces the document.

Inputs

InputEditor fieldType; default; requirementUse
sessionSession nameStringdefault DefaultoptionalA nonblank name such as sample⁠. If omitted, Default is used. Other session actions need the same name.
inputTypeSource inputJsonInputTypedefault fileoptionalfile reads File path. text reads Payload. Only the selected source is used.
filePathFile pathStringdefault ""optionalShared
dataPayloadStringdefault ""optionalFor text⁠: JSON text, or a String variable that holds it, such as {"name":"ada","age":36}⁠.

Outputs

OutputTypeMeaning
sessionStringThe session name, such as sample⁠. Save it in $jsonSession$ and use it in later Session name fields.

Example

Set Session name=sample, Source input=text and Payload=the JSON in Prerequisites. Save the output in the String $jsonSession$. Or make samples/document.json with the same text and set Source input=file and File path=samples/document.json.

Expected result

The output is sample, and Get node value for name gives ada. Bad JSON, an empty source, input over the limits or a file that cannot be read fails, and no document is saved.

Back to actions

Convert JSON to Dictionary (jsonToDictionary)

Convert the root object to a Dictionary. Each value keeps its JSON type.

Inputs

InputEditor fieldType; default; requirementUse
sessionSession nameStringdefault ""requiredShared

Outputs

OutputTypeMeaning
resultDictionaryThe root keys with typed values. Nested lists become List values, and nested objects become Dictionary values. null becomes empty String. Save it in $person$⁠.

Example

Set Session name=sample. Save result in the Dictionary $person$.

Expected result

The Dictionary holds String name=ada, Number age=36, and the Lists tags and users. An empty object gives an empty Dictionary. A list or a single value as the root fails.

Back to actions

Update node value (jsonUpdateNodeValue)

Change a node that exists in the session. For a list, the value is added at the end, unless you choose to replace the list.

Inputs

InputEditor fieldType; default; requirementUse
sessionSession nameStringdefault ""requiredShared
nodePathNode pathStringdefault ""requiredShared. $ updates the root. A missing or null node fails.
replaceArrayValueReplace array node with a new valueBooleandefault falseoptionalFor a list node: false adds the value at the end, and a List value adds each of its items. true replaces the whole list. Any other node is always replaced.

Also uses the value fields.

Outputs

None.

Example

Set Session name=sample, Node path=tags, Value type=String, stringVal=z and Replace array node with a new value=false. To replace the list instead, choose Value type=List, listVal=$tags$ with only the String q, and set the replace field to true.

Expected result

The first step changes tags to ["x","y","z"]. The replace step changes it to ["q"]. No file changes.

Back to actions

Validate (jsonValidate)

Check the JSON format, the type of one node, or a simple schema. It needs no session. Use the valid value of the result for decisions.

Inputs

InputEditor fieldType; default; requirementUse
inputTypeSource inputJsonValidateInputdefault textoptionalfile reads File path. text reads Payload. dictionary reads Dictionary variable. Only the selected source is read.
filePathFile pathStringdefault ""optionalShared
jsonDataPayloadStringdefault ""optionalFor text⁠: the JSON text, such as {"age":36}⁠. Empty text fails the step. Bad JSON gives valid=false⁠.
dictionaryDataDictionary variableDictionarydefault {}optionalFor dictionary⁠: a Dictionary variable such as $person$⁠. It is turned into JSON text first.
validationLevelValidation LevelJsonValidationLeveldefault FormatoptionalFormat⁠: the syntax only. Node⁠: the syntax and the type of one node. Schema⁠: a check against JSON Schema. This is an action with a result, not a condition.
nodePathNode key or pathStringdefault ""optionalFor Node⁠: the path to check, such as age⁠. Shared.
valueTypeValue typeJsonNodeTypedefault StringoptionalFor Node⁠: String⁠, Number⁠, Boolean⁠, ListArray⁠, DictionaryObject or Null⁠. It checks the JSON type and does not convert it. Null also accepts a missing path.
jsonSchemaJSON SchemaStringdefault ""optionalFor Schema⁠: schema text, such as {"type":"object","required":["age"],"properties":{"age":{"type":"number"}}}⁠. Only type⁠, required⁠, properties⁠, items and enum are checked, and other keywords are ignored. type is one of object⁠, array⁠, string⁠, boolean⁠, number⁠, integer or null⁠, and an unknown type makes no type check. integer accepts any number, also with a fraction. enum compares the text of values, so 1 and "1" match. A schema that is not an object checks nothing.

Outputs

OutputTypeMeaning
resultDictionaryBoolean valid and String message⁠. Save it in $validation$ and test $validation.valid$⁠. The message is empty when valid, and says what is wrong when not.

Example

Set Source input=text, Payload={"age":36}, Validation Level=Node, Node key or path=age and Value type=Number. Save result in the Dictionary $validation$. For a schema check, choose Schema and JSON Schema={"type":"object","required":["age"],"properties":{"age":{"type":"number"}}}.

Expected result

Both examples give valid=true and an empty message. With Value type=String, valid=false and the message names the mismatch. Bad JSON or a bad schema gives valid=false. A file or input error still fails the step.

Back to actions