I've using Laravel, loading a db row into an Eloquent object. One of the columns is longtext, a JSON encoded array > 2 million characters long. The original error I was getting was json_decode failing on this column's value.
I tested in tinker. Simplified test code:
$item = Item::find(1);
echo $item->long_text_field;
var_dump(json_decode($item->long_text_field));
echo strlen($item->long_text_field);
On my local vagrant instance this shows the correct values.
...long json array in text, same as the value in the actual DB entry...
...var_dump of json array...
2334040
However on my remote dev server I'm getting
...long json array truncated in the middle...
NULL
1048576
Obviously the json_decode is failing because the string is truncated.
It truncates at a piece like this
"Eff Date":"1\”
Which should be
"Eff Date":"1\/30\/14 16:13”
There's a lot of escaped slashes like that in the longtext, and no strange characters at that point I can see. Does anyone have an idea why this text would truncate like that on one server and not another?