flatten instance_ids list, add json dump and load options