php - Google Maps Places API 返回无效 JSON
问题描述
谷歌地图正在返回https://jsonlint.com/标记为无效 JSON 的内容。人们留下的评论中有转义单引号的问题。所以像:
{
"author_name": "Darrell McClendon",
"author_url": "https://www.google.com/maps/contrib/105899976805332994558/reviews",
"language": "en",
"profile_photo_url": "https://lh4.googleusercontent.com/-XmJwNWWFIfM/AAAAAAAAAAI/AAAAAAAAAAA/ACHi3rfAh9eFXs0wNVHCkZgXEc5k2MwXsg/s128-c0x00000000-cc-rp-mo-ba3/photo.jpg",
"rating": 4,
"relative_time_description": "10 months ago",
"text": "Not hard to get here. From I-10 w, turn right into Central Ave. Turn right onto 12th st, and park by the first gate on right. You check in there, but then drive thru the 2nd gate. Can\'t stay in the truck while unloading",
"time": 1528824337
}
...是一个问题(参见“文本”值)。在此运行 json_decode 将返回 null。
这通常是一个问题吗?尽管上周都在同一个位置进行了测试,但直到今天早上,我才在处理当前的应用程序时遇到它。我可以确认我已经记录了同一个请求的结果,并且它不包含转义的单引号,这就是它当时解码正常的原因。
解决方案
推荐阅读
- c++ - 播放使用 FFMPEG 创建的分段 MP4 时出现问题
- java - 内在候选静态方法引用会在一段时间后消失?
- c# - 我如何用键设置一个布尔值并让它像一个开关
- javascript - 从承诺待处理的 JS 中获取价值
- ios - applescript:如何在多个窗口中执行击键
- python-3.x - 如何绘制具有数值的列与具有非数值的列?
- laravel - 将变量作为 Markdown 传递
- reactjs - 无法在反应引导下拉菜单中集中输入
- javascript - Javascript - 数据分箱的最佳方式
- git - 如何设置我的本地 Git 存储库以使用我刚刚创建的新个人访问令牌?