Common JSON Objects

Version: 1.0 | Release Date: 30/6/2018

This section introduces common JSON objects accepted or returned by M18 in various web service requests.

SqlTable

SqlTable is a Java Class widely used by M18. You can see its detailed source code in Github.

If your programming language is Java, you can use the class definitions obtained on github to convert JSON directly into Java classes for subsequent operations. Its JSON format is shown below:

The SqlTable JSON:

{
  "name":"test",		//SqlTable name
  "size":2, 			//The row count
  "fields":[			//The fields info of the table 
		{
          "name":"id",							// Field name
          "fieldClassName":"Long", 				// Class name of the field
          "fieldClass":"java.lang.Long",		// Field class
          "classType":10
        },
    	{
          "name":"code",
          "fieldClassName":"String",
          "fieldClass":"java.lang.String",
          "classType":0
        },
    	{ 
          "name":"lastModifyDate",
          "fieldClassName":"Date",
           "fieldClass":"java.util.Date",
           "classType":21
        }],
 "values":[			//The values of the field
       {
         "id":3,
         "code":"AS0221",
         "lastModifyDate":"2017-10-25 12:06:34"
       },					
       {
         "id":2,
         "code":"DS22",
         "lastModifyDate":"2017-10-19 09:37:10"
       }]
}

The parameters of SqlTable:

Name Type Description
name String SqlTable name (as stated in data dictionary)
size int The row count
fields JSON Array The fields info of the table
values JSON Array The values of the field

SqlEntity

SqlEntity is a JSON object representing data of a record in a module in M18. Notice that a SqlEntity can contain many SqlTables.

The SqlEntity JSON:

{
	"moduleType":"employee",			//Module name
	"mainTableName":"employee",			//The main table of the module
	"subTableNames":"employeepic;employee_attach", // Sub table name list,separate by ";"
	"employee": a sqlTable to json string ,		//The json can refer to the above sqltable
    "employeepic": a sqlTable to json string ,
	"employee_attach" : a sqlTable to json string 
}

The parameters of SqlEntity:

Name Type Description
moduleType String Module type (as stated in Data Dictionary)
mainTableName String The main table of the module
subTableNames String Sub table name list, separated by semicolon ;
the name of mainTable SqlTable json string The SqlTable JSON
the name of subTable1 SqlTable json string The SqlTable JSON
the name of subTable2 SqlTable json string The SqlTable JSON
... ... ...

CheckMsg

CheckMsg is a JSON object representing the result info/ messages of various web services in M18.

The CheckMsg JSON:

{
    "id":101905,
   	"key":"core_101905",
  	"pass":false,	//When the operation is success, it will be yes;
 	"type":"Error",	//It can be "Error","Info","Warning"
    "info":"required. field(module.required)",		//Info show to ap
    "info_desc":"Required field is empty.",			//Info show to user
  	"exception":"",			//If an exception occurs,exception message will write here.
    "htmlMessage":false,	
    "jsonStr":"",
    "locators":[			//You can find which table and column are wrong with these infos;
            {				
             "colName":"desc",
             "id":0,
             "locatorKey":"employee.desc",
             "row":0,			//Row is only for footer table,for headerTable the row should 0
             "tableName":"employee",
             "type":"Field"
            },
    		{
              "colName":"dept",
              "id":0,
              "locatorKey":"employee.dept",
              "row":0,
              "tableName":"employee",
              "type":"Field"
            }],
   
    "trace":"[ModuleChecker.checkFieldDataDictSetting_458]-[CheckerLib.runChecker_225]-[CawEntityCurdAction.updateEntity_107]-[CawEntityInterceptor.logCall_42]-[view24.updateEntity_-1]"	//You can trace the error in java code with this info.
    
}

The parameters of CheckMsg:

Name Type Description
id long Unique in one app
key String Unique in one app
pass boolean When the operation is success, it will be yes
type String Message type
info String The JSON can refer to the above SqlTable
info_desc String The JSON can refer to the above SqlTable
exception String Exception message
htmlMessage boolean If the message use html code, it will be true
jsonStr json String some special value
locators json Array You can find which table and column are wrong with these infos
trace String The info of java code which returns the error

Other Useful Class

M18 provides other common POJO class definitions and Util methods on Github. If your programming language is Java, include these classes in your path.

  1. CheckResult
  2. EntityResult
  3. LocatorType
  4. MsgLocator
  5. MsgType
  6. SqlClassType
  7. SqlTableField
  8. SqlTableIterator
  9. Util