wp_insert_term doesn’t want to enter its data into custom taxonomy

so I’m working on a code to take data from an array and put it in a custom taxonomy using wp_insert_tem, but the data won’t go in. this is the json i want to fetch, this is from a url

{ "genres": [     {       "name": "Military"     },     {       "name": "Sci-fi"     },     {       "name": "Shounen"     }   ], } 

this is the code i made

$  result = file_get_contents($  url); $  array = json_decode($  result, true); foreach($  array['genres'] as $  gen){     wp_insert_term(         $  gen["name"],         "genres",         array(             "description" => "",             "slug" => sanitize_title($  gen["name"]),         ),    ); } 

please help me