OpenJsonDocument

TwinCAT
Local File and directory access JSON reader

ns=2;s=DEPRAG Smart/Local/FileAndDirectoryAccess/Json/OpenJsonDocument

The command opens a JSON file for further processing. The reader can be retrieved from the ActiveJsonDocuments list using the returned index.

Parameters:

Returns:

    OpenJsonDocument
    A variable of type OpcMethodReturnValueInt32. The Result property contains the command-specific return values.
      Result
      Unique index to retrieve the JSON document in the ActiveJsonDocuments list.

Examples:

In addition to the parameters already explained, the following variables must be created / transferred for the implementation in TwinCAT 3:

Beckhoff parameter:

    bJsonOpenJsonDocument
    A boolean variable that can be used to trigger the execution of the OpenJsonDocument command.
    OutputDataJsonOpenJsonDocument
    An instance of the "ST_JsonDocumentOutputData" structure into which the return value of the OpenJsonDocument method is written.
    hrJsonOpenJsonDocument
    This can be used to monitor the execution of the command. Error codes have the type "HRESULT".
    fbJson
    An instance of the "FB_Json" function block supplied with the DEPRAG Smart library.
    sfullFilePath
    A STRING(255) variable containing the path of the JSON file.
    ConnectionHandle
    "ConnectionHandle" received when establishing a connection between DEPRAG Smart Server and your OPC UA client.


VAR
   bJsonOpenJsonDocument   : BOOL;
   OutputDataJsonOpenJsonDocument   : ST_JsonDocumentOutputData;
   hrJsonOpenJsonDocument  : HRESULT;

   fbJson : FB_Json;
END_VAR

hrJsonOpenJsonDocument := fbJson.OpenJsonDocument(
         bExecute     := bJsonOpenJsonDocument,   
         ConnectionHandle  := depragSmartConnection.ConnectionHandle, 
         sfullFilePath   := 'C:\Test\Test.json',
         OutputData    => OutputDataJsonOpenJsonDocument);
IF hrJsonOpenJsonDocument <> S_FALSE THEN 
  bJsonOpenJsonDocument := FALSE;
END_IF
                                                    

For examples and explanations regarding the calls of nodes via Siemens TIA Portal please refer to the sub-menu "Siemens TIA Portal" in section "Getting Started".