Topics: |
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.
How to: |
Reference: |
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.
The Applications page opens.
The Connect to Data page opens.
Depending on the type of adapter you chose, one of the following options appears on the context menu.
The button may be labeled Next, Create Synonym, Create Base Synonyms, Create Cluster Synonym, or Update Base Synonyms.
The synonym creation process for most adapters has been consolidated so that you can enter all necessary parameters on one page. However, for some adapters such as LDAP, you must click Next buttons until you get to a page that has a Create Synonym button.
The synonym is created and added under the specified application directory.
Note: When creating a synonym, if you choose the Validate check box (where available), the server adjusts special characters and checks for reserved words. For more information, see Validation for Special Characters and Reserved Words.
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)
Enables you to select a document instance from a URL. This selection requires a Base Location, Document Name, and Document Extension.
Defines the location of the document instance.
Enter the name of the JSON document.
Enter the document extension. The default is JSON.
Clicking this button enables you to create the synonym from the document instance.
Create Synonym for JSON (Step 2 of 2)
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.
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.
Indicates the name that will be assigned to the synonym. To assign a different name, replace the displayed value.
Select an application directory. The default value is baseapp.
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.
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.
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 available options.
For a list of options, see Synonym Management Options.
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.
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, $
The Select mapping source dialog box opens.
The Column mapping dialog box opens displaying two rows from the column that is being pivoted.
Examine the data to make sure it looks like JSON.
The resulting Master File contains the definition of the JSON data, represented as a new DUMROOT segment with SEGSUF=JSON, which appears in the Text View pane following the original RDBMS segment.
You can expand DUMROOT to see the names of the fields found in the JSON.
You can right-click DUMROOT to see the values of those fields.
The Master File might now look as follows, with the DUMROOT segment containing the data from the JSON column:
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=DUMROOT, SEGTYPE=S0, SEGSUF=JSON , PARENT=TESTJSON, POSITION=GLOSS, $ FIELDNAME=DUMROOT, ALIAS=JSON_DUMMY_EL, USAGE=A1, ACTUAL=A1, 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, $
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:
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, $
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, $
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.
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.
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.
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 |
WebFOCUS | |
Feedback |