READ

The READ command is used to read and parse the JSON data.

When the READ command is executed, the following steps occur:

1.The file content is read as UTF-8 data and parsed .

 

                                                          Required

 

 READ ------------ FILE ------------ file path ------------------>

 

                                                          Optional

 

               >-- ARCHIVE --------- value ----------------------|

 

Keywords

FILE

This keyword is used to specify the file name and path of the JSON document.

It is recommended to use the forward slash as the path separator and to avoid the use of the DOS drive designator.

The format of the path should be as follows:

For Windows you can specify:

  • Absolute path
    For example:
    /orders/order.json
    C:/orders/order.json

    C:\orders\order.json


    or
  • Relative path.
    For example, orders/order.json (note, no '/' at the start), in which case the order.json document must reside in the orders directory under the JSM Instance directory on your server.

For the IBM i you can specify:

  • Absolute path.
    For example:
    /orders/order.json

    or
  • Relative path.
    For example, orders/order.json (note, no '/' at the start), in which case the order.json document must reside in the orders directory under the JSM Instance directory on your server.

Note: Whatever directory structure you specify must already exist.

This keyword is mandatory.

ARCHIVE

Refer to ARCHIVE for more complete information on this keyword.

This keyword is optional.

Comments / Warnings

The ARCHIVE keyword is a very useful way to store away JSON documents after they have been processed.

Examples

RDML

 

* Define the fields used by the JSM Commands

DEFINE FIELD(#JSMSTS) TYPE(*CHAR) LENGTH(020)

DEFINE FIELD(#JSMMSG) TYPE(*CHAR) LENGTH(256)

DEFINE FIELD(#JSMCMD) TYPE(*CHAR) LENGTH(256)

 

CHANGE FIELD(#JSMCMD) TO('READ FILE(orders/order.json) ARCHIVE(archive/arc_order.json)') 

USE BUILTIN(JSM_COMMAND) WITH_ARGS(#JSMCMD) TO_GET(#JSMSTS #JSMMSG)

 

RDMLX

 

* Define the fields used by the JSM Commands

Define FIELD(#JSMSTS) TYPE(*CHAR) LENGTH(020)

Define FIELD(#JSMMSG) TYPE(*CHAR) LENGTH(256)

Define FIELD(#JSMCMD) TYPE(*CHAR) LENGTH(256)

Define FIELD(#JSMHND) TYPE(*CHAR) LENGTH(4)

 

#JSMCMD := 'READ FILE(orders/order.json) ARCHIVE(archive/arc_order.json)'

Use BUILTIN(JSMX_COMMAND) WITH_ARGS(#JSMHND #JSMCMD) TO_GET(#JSMSTS #JSMMSG)