json string from mysql db and extract json fields

Four Stars

json string from mysql db and extract json fields

One column "Unknown" in local mysql db table has following 2 sample rows:

{"sourceData":{"1":"RPT_DT_ID","2":"APPL_SRCE_CD","3":"BASIC_CM_NO","4":"CHRG_LEND_ON_CHRG_CD"}}
{"sourceData":{"1":"20171231","2":"US","3":" 019044037984006","4":"Lend "}}

 

 

So essentially, each row is a json string.

I need to import from db and then extract the json values and map it to output columns in another table in local mysql db

 

I imported this column and wrote it to tfileoutputjson and I get something like this:

 

[{"file_record":"{\"sourceData\":{\"a\":\"RPT_DT_ID\",\"b\":\"APPL_SRCE_CD\",\"c\":\"BASIC_CM_NO\",\"d\":\"CHRG_LEND_ON_CHRG_CD\"}}"},
{"file_record":"{\"sourceData\":{\"a\":\"20171231\",\"b\":\"US\",\"c\":\" 019044037984006\",\"d\":\"Lend \"}}"}]

 

I need help in extracting this json data, store in csv and map to output fields

Community Manager

Re: json string from mysql db and extract json fields

Hi vshivkaushik

You can use tExtractJsonFields to extract data from the json string, you don't need to write the json string to a file, the job design looks like:

tMysqlInput--main--tExtractJsonFields--tMysqlOutput

 

please refer to the component documentation and learn this component, let me know if you have any issues. 

 

Regards

Shong

 

----------------------------------------------------------
Talend | Data Agility for Modern Business

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog