Managing JSON Metadata

In this section:

When the server accesses a data source, it needs to know how to interpret the data that it finds. For each data source the server will access, you create a synonym that describes the structure of the data source and the server mapping of the JSON data types.


Top of page

x
Creating Synonyms

How to:

Reference:

x

Synonyms define unique names (or aliases) for each JSON data structure that is accessible from a server. Synonyms are useful because they hide the location and identity of the underlying data source from client applications. They also provide support for extended metadata features of the server such as virtual fields and additional security mechanisms.

Using synonyms allows an object to be moved or renamed while enabling client applications to continue functioning without modification. The only modification required is a redefinition of the synonym on the server. The result of creating a synonym is a Master File and Access File based on a given JSON document.



x
Procedure: How to Create a Synonym

To create a synonym, you must have previously configured the adapter. You can create a synonym from the Applications or Adapters pages of the Web Console.

  1. From the Web Console menu bar, click Applications.

    The Applications page opens.

  2. Click the New button and select Synonym from the drop-down menu.

    The Select adapter to configure or Select connection to create synonym pane opens.

  3. Click a connection for the configured adapter.

    The first of a series of synonym creation panes opens.

  4. Enter values for the parameters required by the adapter as described in the synonym creation parameters reference.
  5. After entering the parameter values, click Create Synonym.

    The Status pane indicates that the synonym was created successfully.

The synonym is created and added under the specified application directory.

Note:



x
Reference: Synonym Creation Parameters for JSON

The following list describes the parameters for which you will need to supply values, and related tasks you will need to complete in order to create a synonym for the adapter. These options may appear on multiple panes. To advance from pane to pane, click the buttons provided, ending with the Create Synonym button, which generates the synonym based on your entries.

You can create a synonym based on a JSON document:

Select Document Instance parameters (Step 1 of 2)

Use HTTP URL

Enables you to select a document instance from a URL. This selection requires a Base Location, Document Name, and Document Extension.

Base Location

Defines the location of the document instance.

  • If Use HTTP URL is not selected, enter a physical path or application directory and the JSON document name, or click the ellipsis (...) to navigate to the document.
  • If Use HTTP URL is selected, enter the http address of a directory that contains the JSON document you are using to create the synonym. (This functionality is not available when the JSON document is a local file.) The URL must start with http:// or https://.
Document Name

Enter the name of the JSON document.

Document Extension

Enter the document extension. The default is JSON.

Create Synonym based on Document Instance

Clicking this button enables you to create the synonym from the document instance.

Create Synonym for JSON (Step 2 of 2)

Validate

Select the Validate check box if you wish to convert all special characters to underscores and perform a name check to prevent the use of reserved names. (This is accomplished by adding numbers to the names.) This parameter ensures that names adhere to specifications. See Validation for Special Characters and Reserved Words for more information.

When the Validate option is unchecked, only the following characters are converted to underscores: '-'; ' '; ' \'; '/'; ','; '$'. No checking is performed for names.

Make unique

Select the Make unique check box if you wish to set the scope for field and group names to the entire synonym. This ensures that no duplicate names are used, even in different segments of the synonym. When this option is unchecked, the scope is the segment.

Synonym Name

Indicates the name that will be assigned to the synonym. To assign a different name, replace the displayed value.

Application

Select an application directory. The default value is baseapp.

Prefix/Suffix

If you have tables with identical table names, assign a prefix or a suffix to distinguish them. For example, if you have identically named human resources and payroll tables, assign the prefix HR to distinguish the synonyms for the human resources tables. Note that the resulting synonym name cannot exceed 64 characters.

If all tables and views have unique names, leave the prefix and suffix fields blank.

Overwrite Existing Synonyms

To specify that this synonym should overwrite any earlier synonym with the same fully qualified name, select the Overwrite existing synonyms check box.

Note: The connected user must have operating system write privileges in order to recreate a synonym.



x
Reference: Managing Synonyms

Once you have created a synonym, you can right-click the synonym name in the Adapter navigation pane of either the Web Console or the Data Management Console to access the following options.

Option

Description

Open

Opens the Master File for viewing and editing using a graphical interface. If an Access file is used it will be also available.

Edit as Text

Enables you to view and manually edit the Master File synonym.

Note: To update the synonym, it is strongly recommended that you use the graphical interface provided by the Open option, rather than manually editing the Master File.

Edit Access File as Text

Enables you to view and manually edit the Access File synonym.

Note: This option is available only when an Access File is created as part of the synonym.

Sample Data

Retrieves up to 20 rows from the associated data source.

Data Profiling

Data Profiling provides the data characteristics for synonym columns.

Alphanumeric columns provide the count of distinct values, total count, maximum, minimum, average length, and number of nulls.

Numeric columns provide the count of distinct values, total count, maximum, minimum, average value, and number of nulls.

Refresh Synonym (if applicable)

Regenerates the synonym. Use this option if the underlying object has been altered.

Data Management

Followed by these options, if applicable:

Recreate DBMS Table. Recreates the data source table. You are asked to confirm this selection before the table is regenerated. (Note that the table will be dropped and recreated. During the process, data may be lost.)

Delete All Data. Deletes all existing data. You are asked to confirm this selection before the data is deleted.

Insert Sample Data. Inserts specified number of sample records, populating all fields with counter values.

Reorganize. Recreates the data source table preserving original data.

Note: This option is not available in the Web Console.

Impact Analysis

Generates reports on procedures, synonyms, and columns that provide information on the flows/stored procedures available on a particular server, and the synonyms and columns they use. These reports enable you to evaluate changes before they are made by showing which components will be affected. See the Server Administration for UNIX, Windows, OpenVMS, IBM i, and z/OS manual for details about Impact Analysis reports.

Copy

Copies the synonym to the clipboard.

Delete

Deletes the synonym. You are asked to confirm this selection before the synonym is deleted.

Cut

Deletes the synonym and places it on the clipboard.

Properties

Displays the properties of the synonym, including physical location, last modified date, description, and privileges.



x
Accessing JSON Documents From a Relational DBMS JSON Data Type

How to:

JSON documents might be stored in any fields or columns in any data source. Reporting from such documents is supported by defining their structure as subtrees attached to a parent segment which describes the original data.

The synonym creation process must be run against the data in the DBMS and against the JSON document. The two Master Files must then be combined to make the JSON Master File a child of the Master File created against the DBMS. A FILEDEF is not needed in this instance.



x
Procedure: How to Access JSON Data From an RDBMS Using Web Console or Data Management Console Tools
  1. Using the Web Console or the Data Management Console Create Synonym facility, generate a synonym for an RDBMS data source that contains a column of JSON data. Regardless of the data type used to contain the JSON data in the native data source, it will be mapped as a TX column in the Master File synonym. (For many RDBMS, the CLOB data type is mapped to TX.)
  2. Open the generated Master File in the Synonym Editor. The Master File appears in the right pane in Text View. For example, the Master File for a Progress data source might look as follows:
    FILENAME=TESTJSON, SUFFIX=DB2     , $
    SEGMENT=TESTJSON, SEGTYPE=S0, $
    FIELDNAME=STORE, ALIAS=STORE, USAGE=A30, ACTUAL=A30, $
    FIELDNAME=ADDRESS, ALIAS=ADDRESS, USAGE=A20, ACTUAL=A20,
    MISSING=ON, $
    FIELDNAME=GLOSS, ALIAS=GLOSS, USAGE=TX50, ACTUAL=TX,
    MISSING=ON, $
  3. From the DMC, click a column described as TX. The pop-up menu contains the Map External XML.
  4. Map External XML. This option reads the JSON data directly and creates the structure. The resulting Master File contains the definition of the JSON data, represented as a new segment called SEGSUF=JSON, which appears in the Text View pane following the original RDBMS segment. The Master File might now look as follows:
    FILENAME=testjson, SUFFIX=DB2     , $
      SEGMENT=TESTJSON, SEGTYPE=S0, $
        FIELDNAME=STORE, ALIAS=STORE, USAGE=A30, ACTUAL=A30, $
        FIELDNAME=ADDRESS, ALIAS=ADDRESS, USAGE=A20, ACTUAL=A20,
          MISSING=ON, $
        FIELDNAME=GLOSS, ALIAS=GLOSS, USAGE=TX50, ACTUAL=TX,
          MISSING=ON, ACCESS_PROPERTY=(INTERNAL), $
      SEGMENT=GLOSSARY, SEGTYPE=S0, SEGSUF=JSON    , PARENT=TESTJSON, POSITION=GLOSS, $
        FIELDNAME=GLOSSARY, ALIAS=glossary, USAGE=A1, ACTUAL=A1,
          MISSING=ON, ACCESS_PROPERTY=(INTERNAL), $
        FIELDNAME=TITLE, ALIAS=title, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSARY, PROPERTY=ELEMENT,  $
        FIELDNAME=GLOSSDIV, ALIAS=GlossDiv, USAGE=A1, ACTUAL=A1,
          MISSING=ON, ACCESS_PROPERTY=(INTERNAL),
          REFERENCE=GLOSSARY, PROPERTY=ELEMENT,  $
        FIELDNAME=TITLE1, ALIAS=title, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSDIV, PROPERTY=ELEMENT,  $
        FIELDNAME=GLOSSLIST, ALIAS=GlossList, USAGE=A1, ACTUAL=A1,
          MISSING=ON, ACCESS_PROPERTY=(INTERNAL),
          REFERENCE=GLOSSDIV, PROPERTY=ELEMENT,  $
        FIELDNAME=GLOSSENTRY, ALIAS=GlossEntry, USAGE=A1, ACTUAL=A1,
          MISSING=ON, ACCESS_PROPERTY=(INTERNAL),
          REFERENCE=GLOSSLIST, PROPERTY=ELEMENT,  $
        FIELDNAME=ID, ALIAS=ID, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSENTRY, PROPERTY=ELEMENT,  $
        FIELDNAME=SORTAS, ALIAS=SortAs, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSENTRY, PROPERTY=ELEMENT,  $
        FIELDNAME=GLOSSTERM, ALIAS=GlossTerm, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSENTRY, PROPERTY=ELEMENT,  $
        FIELDNAME=ACRONYM, ALIAS=Acronym, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSENTRY, PROPERTY=ELEMENT,  $
        FIELDNAME=ABBREV, ALIAS=Abbrev, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSENTRY, PROPERTY=ELEMENT,  $
        FIELDNAME=GLOSSDEF, ALIAS=GlossDef, USAGE=A1, ACTUAL=A1,
          MISSING=ON, ACCESS_PROPERTY=(INTERNAL),
          REFERENCE=GLOSSENTRY, PROPERTY=ELEMENT,  $
        FIELDNAME=PARA, ALIAS=para, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSDEF, PROPERTY=ELEMENT,  $
        FIELDNAME=GLOSSSEE, ALIAS=GlossSee, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSENTRY, PROPERTY=ELEMENT,  $
      SEGMENT=GLOSSSEEALSO, SEGTYPE=S0, PARENT=GLOSSARY, $
        FIELDNAME=GLOSSSEEALSO, ALIAS=GlossSeeAlso, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSDEF, PROPERTY=ELEMENT,  $

    Tip: If you have a TX column that contains multiple JSON formats (for example, a name field and an address field), you can choose Map External JSON multiple times to create a separate SEGSUF=JSON segment for each format.

  5. From the Synonym Editor's File menu, save the updated Master File.


x
Procedure: How to Access JSON Data From an RDBMS Manually

Suppose that you have a table in an RDBMS with one or more columns storing JSON data. In order to report from the JSON data, following these steps:

  1. Create the Master File for the relational data source using the format for that DBMS.
    FILENAME=TESTJSON, SUFFIX=DB2     , $
      SEGMENT=TESTJSON, SEGTYPE=S0, $
        FIELDNAME=STORE, ALIAS=STORE, USAGE=A30, ACTUAL=A30, $
        FIELDNAME=ADDRESS, ALIAS=ADDRESS, USAGE=A20, ACTUAL=A20,
          MISSING=ON, $
        FIELDNAME=GLOSS, ALIAS=GLOSS, USAGE=TX50, ACTUAL=TX,
          MISSING=ON, $
  2. Create a Master File for the JSON document in the column of the RDBMS table. If there are two JSON documents with different formats, you must create a Master File for each one.
  3. Manually combine the Master Files. On each root segment for the JSON Master File, add three fields: position, parent, and segsuf. The POSITION keyword identifies the field containing the JSON document. The PARENT field describes the original data source. The field SEGSUF defines the root segment of a JSON document representing sub-tree. The total length of all fields in the Master File must not exceed the FOCUS limitation of 32k. If it does, the query will fail.
    FILENAME=BASEAPP_GLOSSARY, SUFFIX=JSON    ,
     DATASET=c:\json\glossary.json, $
      SEGMENT=GLOSSARY, SEGTYPE=S0, $
        FIELDNAME=GLOSSARY, ALIAS=glossary, USAGE=A1, ACTUAL=A1,
          MISSING=ON, ACCESS_PROPERTY=(INTERNAL), $
        FIELDNAME=TITLE, ALIAS=title, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSARY, PROPERTY=ELEMENT,  $
        FIELDNAME=GLOSSDIV, ALIAS=GlossDiv, USAGE=A1, ACTUAL=A1,
          MISSING=ON, ACCESS_PROPERTY=(INTERNAL),
          REFERENCE=GLOSSARY, PROPERTY=ELEMENT,  $
        FIELDNAME=TITLE1, ALIAS=title, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSDIV, PROPERTY=ELEMENT,  $
        FIELDNAME=GLOSSLIST, ALIAS=GlossList, USAGE=A1, ACTUAL=A1,
          MISSING=ON, ACCESS_PROPERTY=(INTERNAL),
          REFERENCE=GLOSSDIV, PROPERTY=ELEMENT,  $
        FIELDNAME=GLOSSENTRY, ALIAS=GlossEntry, USAGE=A1, ACTUAL=A1,
          MISSING=ON, ACCESS_PROPERTY=(INTERNAL),
          REFERENCE=GLOSSLIST, PROPERTY=ELEMENT,  $
        FIELDNAME=ID, ALIAS=ID, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSENTRY, PROPERTY=ELEMENT,  $
        FIELDNAME=SORTAS, ALIAS=SortAs, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSENTRY, PROPERTY=ELEMENT,  $
        FIELDNAME=GLOSSTERM, ALIAS=GlossTerm, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSENTRY, PROPERTY=ELEMENT,  $
        FIELDNAME=ACRONYM, ALIAS=Acronym, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSENTRY, PROPERTY=ELEMENT,  $
        FIELDNAME=ABBREV, ALIAS=Abbrev, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSENTRY, PROPERTY=ELEMENT,  $
        FIELDNAME=GLOSSDEF, ALIAS=GlossDef, USAGE=A1, ACTUAL=A1,
          MISSING=ON, ACCESS_PROPERTY=(INTERNAL),
          REFERENCE=GLOSSENTRY, PROPERTY=ELEMENT,  $
        FIELDNAME=PARA, ALIAS=para, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSDEF, PROPERTY=ELEMENT,  $
        FIELDNAME=GLOSSSEE, ALIAS=GlossSee, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSENTRY, PROPERTY=ELEMENT,  $
      SEGMENT=GLOSSSEEALSO, SEGTYPE=S0, PARENT=GLOSSARY, $
        FIELDNAME=GLOSSSEEALSO, ALIAS=GlossSeeAlso, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSDEF, PROPERTY=ELEMENT,  $

    Combined Master file:

    FILENAME=testjson, SUFFIX=DB2     , $
      SEGMENT=TESTJSON, SEGTYPE=S0, $
        FIELDNAME=STORE, ALIAS=STORE, USAGE=A30, ACTUAL=A30, $
        FIELDNAME=ADDRESS, ALIAS=ADDRESS, USAGE=A20, ACTUAL=A20,
          MISSING=ON, $
        FIELDNAME=GLOSS, ALIAS=GLOSS, USAGE=TX50, ACTUAL=TX,
          MISSING=ON, ACCESS_PROPERTY=(INTERNAL), $
      SEGMENT=GLOSSARY, SEGTYPE=S0, SEGSUF=JSON    , PARENT=TESTJSON,
    POSITION=GLOSS, $
        FIELDNAME=GLOSSARY, ALIAS=glossary, USAGE=A1, ACTUAL=A1,
          MISSING=ON, ACCESS_PROPERTY=(INTERNAL), $
        FIELDNAME=TITLE, ALIAS=title, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSARY, PROPERTY=ELEMENT,  $
        FIELDNAME=GLOSSDIV, ALIAS=GlossDiv, USAGE=A1, ACTUAL=A1,
          MISSING=ON, ACCESS_PROPERTY=(INTERNAL),
          REFERENCE=GLOSSARY, PROPERTY=ELEMENT,  $
        FIELDNAME=TITLE1, ALIAS=title, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSDIV, PROPERTY=ELEMENT,  $
        FIELDNAME=GLOSSLIST, ALIAS=GlossList, USAGE=A1, ACTUAL=A1,
          MISSING=ON, ACCESS_PROPERTY=(INTERNAL),
          REFERENCE=GLOSSDIV, PROPERTY=ELEMENT,  $
        FIELDNAME=GLOSSENTRY, ALIAS=GlossEntry, USAGE=A1, ACTUAL=A1,
          MISSING=ON, ACCESS_PROPERTY=(INTERNAL),
          REFERENCE=GLOSSLIST, PROPERTY=ELEMENT,  $
        FIELDNAME=ID, ALIAS=ID, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSENTRY, PROPERTY=ELEMENT,  $
        FIELDNAME=SORTAS, ALIAS=SortAs, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSENTRY, PROPERTY=ELEMENT,  $
        FIELDNAME=GLOSSTERM, ALIAS=GlossTerm, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSENTRY, PROPERTY=ELEMENT,  $
        FIELDNAME=ACRONYM, ALIAS=Acronym, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSENTRY, PROPERTY=ELEMENT,  $
        FIELDNAME=ABBREV, ALIAS=Abbrev, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSENTRY, PROPERTY=ELEMENT,  $
        FIELDNAME=GLOSSDEF, ALIAS=GlossDef, USAGE=A1, ACTUAL=A1,
          MISSING=ON, ACCESS_PROPERTY=(INTERNAL),
          REFERENCE=GLOSSENTRY, PROPERTY=ELEMENT,  $
        FIELDNAME=PARA, ALIAS=para, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSDEF, PROPERTY=ELEMENT,  $
        FIELDNAME=GLOSSSEE, ALIAS=GlossSee, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSENTRY, PROPERTY=ELEMENT,  $
      SEGMENT=GLOSSSEEALSO, SEGTYPE=S0, PARENT=GLOSSARY, $
        FIELDNAME=GLOSSSEEALSO, ALIAS=GlossSeeAlso, USAGE=A55, ACTUAL=A55,
          MISSING=ON,
          REFERENCE=GLOSSDEF, PROPERTY=ELEMENT,  $

Top of page

x
Conversion

The data in a JSON document may reflect dates or numeric values, however, all the fields in a Master File synonym are set to the ALPHA data type.


Top of page

x
Numeric Values

In order to enable arithmetic operations on numeric fields, the data type specified in the USAGE attribute of a numeric field needs to be modified, depending on the data in the JSON document, to one of the following data types: Integer (I), Double Float (D), or Decimal (P). If the data type is modified to Double Float or Decimal, use scale and precision as necessary to describe the data in the JSON document.

Furthermore, it is recommended that the length of the ALPHA data type specified in the ACTUAL attribute of the numeric field be modified to reflect the maximum length of the data in the JSON document.


Top of page

x
Dates in JSON

In order to enable arithmetic operations on dates, the data type specified in the USAGE attribute of a date field needs to be modified, depending on the date format used in the JSON document, to one of the following data types: YYMD, MDYY, or DMYY.

Furthermore, the length of the ALPHA data type specified in the ACTUAL attribute of the date field needs to be modified to 10.

Note:



Example: Using Dates in JSON

If in the JSON document you have the following format:

Then use USAGE=

1996-01-30

YYMD

01-30-1996

MDYY

30-01-1996

DMYY


iWay Software