1. parse the table structure information object of the json object. It is in json format and named tableObj * {* "tableName": "t_res", // table name * "columnInfo ": [// field information * {* "columnName": "id", // field name * "dataTypeName": "varchar", // field type * "isKey": true, // whether it is a primary key, true indicates a primary key, false indicates not * "isAutoIncrement": true, // whether it is auto-incrementing, true indicates auto-incrementing, false indicates not auto-increment * "isNull": 0, // whether it is null, 1 indicates it can be empty, 0 indicates it cannot be blank * "precision": 5, // precision * "defaultValue": "10" // default * "scale": 2 // decimal places *} *] *} try {String name = tableObj. get ("tableName "). toString (); // obtain the table name JSONArray columnInfo = tableObj. getJSONArray ("columnInfo"); // obtain the field description. json array int size = columnInfo. length (); // json array length for (int I = 0; I <size; I ++) {JSONObject info = columnInfo. getJSONObject (I); String cloumn = info. getString ("columnName"); // obtain the field name String dataType = info. getString ("dataTypeName"); // obtain the field type boolean isKey = info. getBoolean ("isKey"); // obtain whether the field is the primary key boolean isAutoIncrement = info. getBoolean ("isAutoIncrement"); // gets whether the field is auto-incrementing. int isNull = info. getInt ("isNull"); // get whether the field is null int precision = info. getInt ("precision"); // obtain the field type precision String defaultValue = info. getString ("defaultValue "); // obtain the default field value} 2. encapsulate the json object/*** obtain the table structure information based on the table name * @ param tableName table name * @ return table structure information object Json format * {* "tableName ": "t_res", // table name * "columnInfo": [// field information * {* "columnName": "id", // field name * "dataTypeName ": "varchar", // field type * "isKey": true, // whether it is a primary key. true indicates that it is a primary key, and false indicates that it is not * "isAutoIncrement": true, // whether the value is auto-incrementing; true indicates auto-incrementing; false indicates no auto-incrementing * "isNull": 0; // whether the value is null; 1 indicates that the value can be null, 0 indicates that the value cannot be blank * "precision": 5, // precision * "defaultValue": "10" // default * "scale ": 2 // decimal places *} *] *} */JSONObject tableInfoObj = new JSONObject (); StringBuffer sb = new StringBuffer (); sb. append ("{" + "'tablename':" + tableName + "," + "'columninfo':" + "["); sb. append ("{" + "'columnname':" + "'" + cloumn + "'" + "," + "'datatypename ': "+" '"+ dataType +"' "+", "+" 'iskey': "+ isKey +", "+" 'precision ":" + precision + ", "+" 'defaultvalue': "+" '"+ defaultValue +"' "+", "+" 'isnull': "+ isNull + ", "+" 'isautosecret': "+ autoIncrement +", "+" 'Scale': "+ scale +"} "+", "); sb. deleteCharAt (sb. length ()-1); sb. append ("]"); sb. append ("}"); // json string to complete the System. out. println (sb. toString (); tableInfoObj = new JSONObject (sb. toString (); // converts a json string to the return tableInfoObj object of jsonObject;