Here is the code I am using. It creates duplicate post every time I refresh. Also, how can I add custom field to my post?
My array looks like this:
[{
    "featured":"",
    "exclusive":"",
    "promo_id":"XXX",
    "offer_id":"1",
    "title" : "Super Cars"
}]
My php code:
<?php 
$json = "url";
$response = file_get_contents($json);
$mydecode = json_decode($response);
for ($i = 10; $i < 15; $i++) {
    $title = str_replace("&", "&", $mydecode[$i]->title);
    $id = $mydecode[$i]->offer_id;
    $link = $mydecode[$i]->link;
    if( $id === "x" ) {
        $new_post = array(
        'post_title' => $title,
        'post_content' => $description,
        'post_status' => 'draft',
        'post_author' => 1,
        'post_type' => 'coupon'
        );
        $post_id = wp_insert_post($new_post);
    }
}
?>
The code successfully inserts posts but duplicate every time I refresh. If anyone can contribute a bit, it would be great!