before you mark this as a duplicate, I've tried probably every relevant question on StackOverflow and nothing seems to be working.
I have a very large JSON file (8112 lines) that I'm trying to convert to an array and then enter the data into a database. So far, I can't even get the JSON to turn into an array.
file.json
[
{
"artistname":"1 Wild Night1",
"publicistName":"Amy Sciarretto",
"publicistEmail":"amy@amysciarretto.com",
"id":"306",
"updated":"2018-02-13 07:23:19",
"website":"",
"outdated":"danger",
"contactid":"175"
},
{
"artistname":"2Cellos",
"publicistName":"Angela Barkan",
"publicistEmail":"angela.barkan@sonymusic.com",
"id":"404",
"updated":"2015-03-11 05:05:12",
"website":"",
"outdated":"danger",
"contactid":"192"
},
{
"artistname":"3 Doors Down",
"publicistName":"Taylor Vaughn",
"publicistEmail":"Taylor.Vaughn@umusic.com",
"id":"760",
"updated":"2016-03-04 09:32:06",
"website":"",
"outdated":"danger",
"contactid":"205"
},
Here are three entries, but there's a bunch more below that. I'm not entirely sure how many there are.
file.php
$arr = json_decode($json, true);
var_dump($arr); // response is NULL
if (is_array($json)) {
foreach($json as $data) {
echo $data['artistname'];
echo $data['publicistName'];
echo $data['publicistEmail'];
}
} else {
echo "not an array"; // this is the response for the if statement
}
What am I doing wrong?
Also, I've tested the entire JSON file on JSONLint and one of the other services, its perfectly valid according to them.