php - json_encode breaks on image url
问题描述
I have a weird issue with json_encode
. I have a table that I dump the user submissions in to for backup, but for some reason lately the image url breaks after a certain length. I'm not sure if it is because the photo is too big, but I don't see any fixes for this other than the JSON_PARTIAL_OUTPUT_ON_ERROR
. Is there any way this can be fixed or some preventative for this?
{"task": [{
"Hours": "12",
"Photo": ["data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBYRXhpZgAATU0AKgAAAAgAAgESAAMAAAABAAEAAIdpAAQAAAABAAAAJgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAADAKADAAQAAAA //It breaks right here
I only put a snippet of the base64 url to save space, but it breaks at the end.
解决方案
The most likely cause of your problem is that the database column you are inserting this data into has a limited size, and the JSON you are inserting is larger than that limit, so it is being truncated.
Solution is simple: change the database schema to allow longer values.
推荐阅读
- python - Pycharm Terminal 似乎没有使用虚拟环境
- google-cloud-platform - 节点没有 storage.objects.create
- java - java中方法调用之前空检查的快捷方式
- typescript - 如何确保一个接口只包含另一个接口的属性?
- php - 在初始化期间在另一个常量中使用一个常量
- android - 如何在android中制作半径边框?
- c - C - 将结构变量从一个函数传递到另一个函数
- networking - VirtualService 路由只使用一台主机
- highcharts - Angular 8 和 Highcharts - 如何显示工具提示十字准线
- php - 由于重定向或服务器资源导致的流量丢失