util.JSON.proposeType

Describes the record structure that can hold a given JSON data string.

Syntax

util.JSON.proposeType(
   source STRING )
  RETURNING result STRING
  1. source is a string value that contains JSON formatted data.
  2. result is a string that represents the definition of a RECORD.

Usage

The util.JSON.proposeType() class method takes a JSON formatted string as parameter and generates the RECORD definition that corresponds to the source JSON string.

This method is useful to define a record variable that must hold the given JSON string.

IMPORT util
MAIN
    DEFINE js STRING
    LET js='{ "cust_num":2735, "cust_name":"McCarlson",
              "orderids":[234,3456,24656,34561] }'
    DISPLAY util.JSON.proposeType( js )
END MAIN

Displays:

 RECORD
    cust_num FLOAT,
    cust_name STRING,
    orderids DYNAMIC ARRAY OF FLOAT
END RECORD