CMIS Connector 25.1
CMIS Connector Help

# parse_json

Parses a string of JSON and returns a JSON value.

## Syntax

    parse_json( json )

## Arguments

Argument | Description
--- | ---
`json` | (string) The input string to parse.

## Returns

(LuaJsonValue). A LuaJsonValue containing the JSON data.

## Example

    local fh = io.open("example_json.json", "r")
    local file_content = fh:read("*all")
    fh:close()

    local myJsonValue = parse_json(file_content)

    if myJsonValue:is_object() then
      document:insertJson( myJsonValue:object() , "MyJsonField" )
    elseif myJsonValue:is_array() then
      document:insertJson( myJsonValue:array() , "MyJsonField" )
    end

If the file `example_json.json` contained the following JSON object:

    {
      "product": "IDOL",
      "component": "CFS",
      "version": { "major": 11, "minor": 3 },
      "ports": [
        { "type": "ACI", "number": 7000 },
        { "type": "Service", "number": 17000 }
      ]
    }

The resulting document might look like this:

    <document>
       <reference>ref1</reference>
       <xmlmetadata>
          <MyJsonField>
            <component>CFS</component>
            <ports>
              <number>7000</number>
              <type>ACI</type>
            </ports>
            <ports>
              <number>17000</number>
              <type>Service</type>
            </ports>
            <product>IDOL</product>
            <version>
              <major>11</major>
              <minor>3</minor>
            </version>
          </MyJsonField>
       </xmlmetadata>
    </document>

## See Also

If you know that the input data is a JSON object, you can also use the function parse_json_object. If you know that the input data is a JSON array, you can also use the function parse_json_array.

Copyright 2024 Open Text
Version 25.1 | Last updated January 2025

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: Knowledge Discovery CMIS Connector 25.1

Topic Title: parse_json