php - JSON对象数组逗号后没有空格
问题描述
这是我的 json 数组:已更新
{
"Title": "Limitless",
"Year": "2011",
"Rated": "PG-13",
"Released": "2011-03-18",
"Runtime": 105,
"Actors": [
"Bradley Cooper",
"Robert De Niro",
"Abbie Cornish",
"Andrew Howard"
]
}
这是我的 php 返回:
return response()->json($movie);
jQuery:
$("#stars").val(data.Actors); //Nothing fancy about this. Just outputting data to an input field.
结果:
Bradley Cooper,Robert De Niro,Abbie Cornish,Andrew Howard
为什么名称/逗号之间没有空格?有没有办法在没有/使用正则表达式的情况下实现这一目标?还是解析错误?
解决方案
你应该把它写成
$("#stars").val(data.Actors.join(', '))
推荐阅读
- javascript - 如何将 matterjs 作为 npm 模块导入到我的 p5 草图中?
- python - Need Help Turning Salesforce Data Requested from Salesforce into Dataframe for Internal Dashboard
- java - org.openqa.selenium.remote.service.DriverService$Builder.createArgs()Lcom/google/common/collect/ImmutableList;与硒 3.5.3 铬 76
- python-3.x - 导入袖扣:无法从“plotly.plotly”导入名称“plot”
- javascript - 使用事件侦听器响应自定义下拉列表
- c# - 如何从其中包含视图的 Xamarin Forms 基类 Page 继承?
- java - Android Studio 中带有 Apache POI 的 ClassNotFoundException
- dynamics-crm - 如何在 Dynamics 365 的数据导入期间停止进程运行?
- python-3.x - 多索引 Pandas DataFrame 上的滚动窗口百分位数排名
- python-2.7 - 为什么有时我得到结果但有时即使我运行相同的代码也没有?