merge json online postgresql 10
I have found a solution:

select array_to_json(array_agg(js.row)) as json from 
( SELECT json_build_object('name', filename)::jsonb || jsonb_object_agg(tags.key, COALESCE(tags.str, CAST(tags.num as varchar(100)))) as row FROM 
(SELECT *, rank() OVER (partition by filename order by created desc) AS rank 
 FROM meta_info m where m.filename like 'DATASETS/14.0/%' ) tt 
inner join tags on tags.file_id=tt.id WHERE tt.rank = 1 group by tt.filename) as js