Convert a JSON string to its corresponding JSON object
Strings, the default output of LLMs, can be converted into other formats.
For example, if you ask an LLM to produce a JSON object, you will need to convert the result (i.e. a JSON string) to
its corresponding JSON object.On this page, we will introduce Relevance’s String to JSON converter. Please keep in mind that we use LLM output as a string example but
the content applies to any JSON string conversion.
Provide the JSON string as the input. In the image below, we pass in the LLM step answer as input into the converter step and
the output is the corresponding JSON object.
Make sure, the input string is a valid JSON otherwise this component will raise an error.When instructing an LLM to generate a JSON object, it is recommended to also set up the
is_json validator.