fluent/fluent-plugin-sql

How to Map a json inside a json to column

Happylinzy opened this issue · 1 comments

If I have a JSON {"id":7, "name":"bob"}, I can use
column_mapping 'id:id, name:name' .

But, for example, I have a JSON like this :
{"id":{"myid":7}, "name":"bob"}

How can I map myid to the column id?

use the trasnfrom record to extract the fields , then use the new vars to inster into the table

ex:

@type record_transformer
enable_ruby true

data ${record.to_json} # Convert full JSON log data to string under "data"
created_at ${Time.now.utc.iso8601} # Store current UTC time

change record.to_json with record["filed"] or something like this, double check the ruby syntax

then in the table:


table table_name
column_mapping 'data:data,created_at:created_at'