Get a Text as a JSON

Converts a string to a JSON object.

Overview

This procedure converts a string to a JSON object by parsing the string content. The string should contain valid JSON syntax. The procedure automatically handles strings that may have extra text before or after the JSON content by identifying and extracting the JSON portion (looking for opening { or [ and corresponding closing } or ]).

Input Concepts

Concept
Type
Description
Required
Default

string

string

The string to be converted into a JSON object

Yes

N/A

Output Concepts

Concept
Description

json

The JSON object obtained from the string conversion

Examples

1. Converting a simple JSON string

This example converts a string containing JSON to a JSON object.

get the string
get the string as json

2. Converting a string with JSON object

This example converts a string representation of a JSON object to an actual JSON object.

the string is '{"name":"John", "age":30, "city":"New York"}'
get the string as json

3. Converting and accessing JSON fields

This example shows converting a JSON string and then accessing its fields. The result would be "0.5% 10 NET 45" for Description and "38" for TermsCode.

the term is "{\"TermsCode\": \"38\", \"Description\": \"0.5% 10 NET 45\"}"
get the term as a json
get the json's Description
get the json's TermsCode

4. Converting a JSON array string

This example demonstrates converting a string containing a JSON array to an actual JSON array with multiple product objects.

the term is "[{\"Product Name\": \"P854282R COMP\", \"Quantity\": \"3\", \"Price\": \"$53.00\", \"Prices\": [\"1\", \"2\"]},{\"Product Name\": \"F854734 COMPR\", \"Quantity\": \"1\", \"Price\": \"$34.95\", \"Prices\": [\"2\", \"3\"]}]"
get the term as a json

5. Converting complex nested JSON

This example shows converting a complex nested JSON structure from a string and then accessing a field. For a JSON with nested objects like {"u_project_name": {"link": "...", "value": "..."}, "state": "4"}, this would return "4".

get the val as a json
get the json's state

Last updated

Was this helpful?