PHP脚本没有将所有数据写入JSON文件

I'm writing JSON data to a file using a php script but for some reason it's not writing all the data.

Here's the JSON

and this is the php script.

<?php
  $myFile = "json/countries.json";
  $fh = fopen($myFile, 'w') or die("can't open file");
  $stringData = json_encode($_POST["data"]);
  fwrite($fh, $stringData);
  fclose($fh);
?>

It's only writing down to Suriname. Does anyone know what might be the problem?

It has worked fine but suddently stopped and I've checked the code but can't see any problem other than the PHP-script.

Not a big PHP programmer so thought I'd ask here and hopefully be able to rule that out.

Thanks!

It's seems that there is no problem with the code. Just sent an AJAX post request on my local server setup (ISS 7.5, PHP 5.6 FAST/CGI) using the JSON string you've provided in the link. I guess on the client side the data is gathered and JSON.stringify is performed on the data to get a JSON object.

When it arrives on the server you json_encode it. This will result in a double encoded JSON object. Just remove json_encode since the data is already formatted correctly as JSON.

Maybe your server somehow truncates the data.