Thank you. I was hoping much of what I do in json in python is already available in kotlin too.
Let me give you a sample, perhaps you can lead me here, I am totally new to Kotlin.
Below are snippets of python code.
// start of Python sample code below
import json
js = json.loads(response[âBodyâ].read()) # read json from AWS S3
# Contents of js document read is this:
{
âenvironmentâ: âproductionâ,
âpostgres_hostâ : âpgstaging-prod.blah.blah.rds.amazonaws.comâ,
âpostgres_portâ : 5432,
âpostgres_databaseâ : âdatawarehouseâ,
âpostgres_userâ : âpguserâ,
âpostgres_passwordâ : â!!!â,
âpostgres_config_schemaâ : âetl_operationsâ,
âpostgres_validation_log_table_nameâ : âjobs_process_logâ,
âpostgres_destination_table_nameâ : âmyleadsâ,
âdebugFlagâ: true,
âconfigBucketâ: âcsn-datalakeâ,
âconfigFileNameâ: âyurib_test/myleads.jsonâ,
âHighWaterMarkFileNameâ: âyurib_test/dts_high_watermark.jsonâ,
ârepartitionSourceTableNameâ: âleadsâ,
ârepartitionSourceDbNameâ: âdatalakeâ,
âsourceTablePartitionDateTimeâ: âjob_run_timestamp_utcâ,
ârepartitionTargetTableNameâ: âoutleadsâ,
ârepartitionTargetDbNameâ: âdatalake_reportsâ,
ârepartitionTargetS3Locationâ: âyurib_test/outleadsâ,
ârepartitionTargetColumnListâ: [
{âcolNameâ: âmessage_item_countrycodeâ, âisDatePartitionâ: false, ârenameToâ : âmessage_countrycodeâ},
{âcolNameâ: âmessage_tenant_codeâ, âisDatePartitionâ: false, ârenameToâ : âmessage_tenantâ},
{âcolNameâ: âmessage_lastupdatedâ, âisDatePartitionâ: true, ârenameToâ : âmessage_lastupdatedâ}
],
ârepartitionLoadTypeâ: âincremental_data_loadâ,
ârepartitionâ: 4,
ârepartitionLoadTypeIncrementalâ: âincremental_data_loadâ,
ârepartitionLoadTypeFullInitialâ: âfull_data_loadâ,
âcountryCodeColNameâ: âmessage_item_countrycodeâ,
âtenantColNameâ: âmessage_tenant_codeâ,
âautoCreateCountryTenantâ: false,
âautoCreateCountryâ: true,
âautoCreateTenantâ: true,
âpartitionDateDefaultâ: â0000-00-00â,
âpartitionYearDefaultâ: â0000â,
âpartitionMonthDefaultâ: â00â,
âpartitionDayDefaultâ: â00â,
âcountryCodeDefaultâ: âAUâ,
âtenantDefaultâ: âCARSALESâ,
âmissingPartColDataValReplaceâ: âMISSINGDATAâ,
âvalidateIncomingCountryTenantâ: true,
âdatePartitionStyleâ: âymâ,
âdatePartitionStyleYearMonthâ: âymâ,
âdatePartitionStyleYearMonthDayâ: âymdâ,
âpropagateGlueJobRunGuidâ: false
}
# here is how Python can access above json document using and range
print (js["repartitionLoadType"])
print (js['configBucket'], js['configFileName'], js['HighWaterMarkFileName'])
print (js['repartitionTargetTableName'], js['repartitionTargetS3Location'])
print (js['repartitionSourceTableName'], js['repartitionSourceDbName'])
print (js['repartitionTargetDbName'], js['repartitionLoadType'])
print (js['autoCreateCountry'], js['autoCreateTenant'], js['missingPartColDataValReplace'])
print (js['countryCodeColName'], js['tenantColName'], js['propagateGlueJobRunGuid'])
print (js['countryCodeDefault'], js['tenantDefault'], js['validateIncomingCountryTenant'], js['repartition'])
partition_dts = ""
# json array
for i in range(0, len(js['repartitionTargetColumnList'])):
if True == js['repartitionTargetColumnList'][i]['isDatePartition']:
partition_dts = "`" + js['repartitionTargetColumnList'][i]['colName'] + "`"
else:
js['repartitionTargetColumnList'][i]['colName'] = "new value replace/assign here"
continue
# to set/replace/assign any values above:
js["repartitionLoadType"] = "some new value"
â end of python code
So I was looking for direction of how to tackle this in Kotlin and what JSON library I can use so I dont have to re-invent the wheel.